...

View Full Version : Select Menu Dropping Down a Space



CoolAsCarlito
10-15-2008, 03:03 AM
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:

<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>



Here's my ajax page:

<?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>";

}

?>

shyam
10-15-2008, 12:46 PM
My question is why does the second select menu drop down a line. Why isn't it beside "Show Name:"?
because its within a div element...change it to span and it will behave (but, thats semantically wrong :O...)


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?

construct the correct html and add it to the innerHTML portion



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum