Select Menu Dropping Down a Space
Posted: Tue Oct 14, 2008 11:29 pm
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
My question is why does the second select menu drop down a line. Why isn't it beside "Show Name:"? One more thing I want to know. When a user selects the showname out of the drop down I want it to take that show name to the DB and match that against all the same shownames and find the one with the highest show label (tiny int.) and and one to the that number and place that into the readonly input text box. How do I do that?
Here's my php page:
Here's my ajax page:
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
My question is why does the second select menu drop down a line. Why isn't it beside "Show Name:"? One more thing I want to know. When a user selects the showname out of the drop down I want it to take that show name to the DB and match that against all the same shownames and find the one with the highest show label (tiny int.) and and one to the that number and place that into the readonly input text box. How do I do that?
Here's my php page:
Code: Select all
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function ajaxGet()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.getElementById('shownam').innerHTML = xmlHttp.responseText;
}
}
//alert("Selected: " + document.getElementById("ajax1").value);
xmlHttp.open("GET","showAjax.php?type=" + document.getElementById("ajax1").value,true);
xmlHttp.send(null);
}
</script>
</head>
<body>
<?php
/* setupshow.php */
/* This form after submission takes the results of the form and makes a new show ready for adding matches. */
require ('database.php');
echo '<form action="setupshow.php" method="post" name="myForm">';
echo '<fieldset>';
echo '<legend>Enter the following information to setup a show:</legend>';
echo '<p>Weekly Show or Pay-Per View:<select name="type" id="ajax1" onChange="ajaxGet();"><option value="">Select a Show Type</option>';
$query = 'SELECT type FROM shows';
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)){
echo "<option value=\"{$row['type']}\">{$row['type']}</option>\r";
}
echo '</select></p>';
echo "<p>Show Name:<div id=\"shownam\"><select id=\"names\"></select></div>";
echo '<p>Show Label:<input name="showlabel" type="text" readonly="true" size="5"></p>';
echo '<p>Location:<input name="location" type="text"></p>';
echo '<p>Arena:<input name="arena" type="text"></p>';
echo '<div align="center"><input name="submit" type="submit" value="Submit"><input name="sumbitted" type="hidden" value="TRUE"></div>';
echo '</fieldset>';
echo '</form>';
?>
</body>
</html>
Code: Select all
<?php
require('database.php');
if(isset($_GET['type']))
{
$type = mysql_real_escape_string($_GET['type'],$link);
$res = mysql_query("SELECT `showname` FROM `shows` WHERE `type` = '".$type."';") or die("ERROR 1");
echo "<select id=\"names\">";
while($list = mysql_fetch_assoc($res))
{
echo "<option value=\"".$list['showname']."\">".$list['showname']."</option>";
}
echo "</select>";
}
?>
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: