Xtremer360 Posted October 15, 2008 Share Posted October 15, 2008 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>"; } ?> Quote Link to comment Share on other sites More sharing options...
grim1208 Posted October 15, 2008 Share Posted October 15, 2008 could you first response $array[0] have a null value? I have had this problem and that has occured, Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 15, 2008 Author Share Posted October 15, 2008 I'm sorry could you rephrase that? Quote Link to comment Share on other sites More sharing options...
grim1208 Posted October 15, 2008 Share Posted October 15, 2008 do you have a blank col. in your db Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 15, 2008 Author Share Posted October 15, 2008 No sir. Quote Link to comment Share on other sites More sharing options...
grim1208 Posted October 15, 2008 Share Posted October 15, 2008 replace echo "<option value=\"".$list['showname']."\">".$list['showname']."</option>"; with if($list['showname'] != "") { echo "<option value=\"".$list['showname']."\">".$list['showname']."</option>"; } see if that works Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted October 15, 2008 Author Share Posted October 15, 2008 I'm sorry it didn't. Quote Link to comment Share on other sites More sharing options...
grim1208 Posted October 15, 2008 Share Posted October 15, 2008 i noticed a possible div name error on your ajax page <div id=\"shownam\"> not sure if that will help or not don't you want it to be showname? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.