MannyG Posted April 28, 2010 Share Posted April 28, 2010 Hey all! The basic premise of what I would like to do is create a drop-down menu (within a form so I can send those values to another page to query them into a database) that upon being clicked narrows down to another drop-down menu which finally narrows down to one more drop down menu. I have the first two working, however the third drop-down does not work. Also I want to know, I am using a form for each of these instances...and another form below this code for textfield input, each dropdown has it's own form, so this file has 4 forms. Is it possible to send all the form data to the same page and retrieve each result still? Here is my code... <?php //grabs codeline from dropdown $getcodeline = $_GET['codeline']; //grabs build from dropdown $getbuild = $_GET['build']; echo "<center><h1><b>Add Info</b></h1></br></center>"; print "\t<form id='sort'>\n"; //Codeline drop down menu (1st drop down, where initial selection occurs) $distinctcodeline = mysql_query("SELECT DISTINCT version FROM build"); echo "<select name='codeline' onchange=\"document.getElementById('sort').submit()\" onselect=\"select()\">"; echo "<option>Select Codeline</option>"; while($search=mysql_fetch_array($distinctcodeline)){ echo"<option>".$search['version']."</option>"; echo "</br>"; } echo "</select>"; print "\t</form>\n"; //here the second dropdown menu starts and it checks if anything has been selected...this actually works... if (isset($getcodeline)){ //select bundle based on codeline selected... $specificBundle = mysql_query("SELECT DISTINCT bundle FROM build WHERE version = '$getcodeline'"); print "\t<form id='sort'>\n"; echo "<select name='bundle' onchange=\"document.getElementById('sort').submit()\" onselect=\"select()\">"; echo "<option>Select Bundle</option>"; while($searching=mysql_fetch_array($specificBundle)){ echo"<option>".$searching['bundle']."</option>"; echo "</br>"; } echo "</select>"; print "\t</form>\n"; } if (isset($getbuild)){ //this is the third one, now the query is a little harder, but it works in mysql and so it should work fine... i am passing the variable $getbuild through it $specificDevice = mysql_query("SELECT DISTINCT build.bundle, build_device_test.build_id, build.build_id, build_device_test.deviceID, devices.devicename, devices.deviceID FROM build, devices, build_device_test WHERE (build.build_id = build_device_test.build_id) AND (devices.deviceID = build_device_test.deviceID) AND (build.bundle = '$getbuild')"); print "\t<form id='sorted'>\n"; echo "<select name='device' onchange=\"document.getElementById('sort').submit()\" onselect=\"select()\">"; echo "<option>Select Device</option>"; while($devicesearching=mysql_fetch_array($specificDevice)){ echo"<option>".$devicesearching['devicename']."</option>"; echo "</br>"; } echo "</select>"; print "\t</form>\n"; } ?> After this the normal form starts. I would like to add, the variable that is called '$getbuild' I tried echoing it (to see if the selection shows from dropdown menu 2) but it did not appear, so I am not sure if that may be one of the problems or not o__O Any help is greatly appreciated, thank you! Quote Link to comment Share on other sites More sharing options...
ialsoagree Posted April 28, 2010 Share Posted April 28, 2010 As to your first problem: $getbuild = $_GET['build']; But you define the name of the select as "bundle" - not build: echo "<select name='bundle' ... The browser will only submit form values for the form that was told to submit. You can keep everything in the same form by altering your if statements by adding an "else" clause: if (isset($getcodeline)){ .... } else { print "\t</form>\n"; } Then you need to delete all your "print "\t</form>\n";" where they appear currently (except in the last if statement), and remove the "print "\t<form id='sort'>\n";" within the if statements. Quote Link to comment Share on other sites More sharing options...
MannyG Posted April 28, 2010 Author Share Posted April 28, 2010 Sorry yeah I noticed the first error few minutes after posting, forgot to update...however for the part where I make it all form, I did that and it show's correctly except the last drop down still does not show. Also when I echo out $getbuild it does not return the value selected, returns nothing...but $getcodeline returns whatever value that is selected. Quote Link to comment Share on other sites More sharing options...
MannyG Posted April 28, 2010 Author Share Posted April 28, 2010 Okay here is the weird thing...it works under these conditions (by works I mean all three menus show and it displays the $getbuild value... When I select an item from the first dropdown... Then the second dropdown appears and I select an item from there... Then I go back to the first dropdown and select a different value, it seems to send these values (it shows in URL since I am using $_GET) AND with these values sent and registered, the THIRD dropdown appears. Ideas..? Quote Link to comment Share on other sites More sharing options...
ialsoagree Posted April 28, 2010 Share Posted April 28, 2010 Need to see how you've changed the code. Quote Link to comment Share on other sites More sharing options...
MannyG Posted April 28, 2010 Author Share Posted April 28, 2010 <?php //grabs codeline from dropdown $getcodeline = $_GET['version']; echo "<center><h1><b>Add Info</b></h1></br></center>"; print "\t<form id='sort'>\n"; //Codeline drop down menu $distinctcodeline = mysql_query("SELECT DISTINCT version FROM build"); echo "<select name='version' onchange=\"document.getElementById('sort').submit()\" onselect=\"select()\">"; echo "<option>Select Codeline</option>"; while($search=mysql_fetch_array($distinctcodeline)){ echo"<option>".$search['version']."</option>"; echo "</br>"; } echo "</select>"; echo $getcodeline; $getbuild = $_GET['bundle']; if (isset($getcodeline)){ //select bundle based on codeline selected... $specificBundle = mysql_query("SELECT DISTINCT bundle FROM build WHERE version = '$getcodeline'"); echo "<select name='bundle' onchange=\"document.getElementById('sorted').submit()\" onselect=\"select()\">"; echo "<option>Select Bundle</option>"; while($searching=mysql_fetch_array($specificBundle)){ echo"<option>".$searching['bundle']."</option>"; echo "</br>"; } echo "</select>"; echo $getbuild; } if (isset($getbuild)){ //select device based on bundle selected... $specificDevice = mysql_query("SELECT DISTINCT build.bundle, build_device_test.build_id, build.build_id, build_device_test.deviceID, devices.devicename, devices.deviceID FROM build, devices, build_device_test WHERE (build.build_id = build_device_test.build_id) AND (devices.deviceID = build_device_test.deviceID) AND (build.bundle = '$getbuild')"); echo "<select name='device' onchange=\"document.getElementById('sort').submit()\" onselect=\"select()\">"; echo "<option>Select Device</option>"; while($devicesearching=mysql_fetch_array($specificDevice)){ echo"<option>".$devicesearching['devicename']."</option>"; echo "</br>"; } echo "</select>"; } else { print "\t</form>\n"; } ?> This is what it look's like now. Quote Link to comment Share on other sites More sharing options...
ialsoagree Posted April 28, 2010 Share Posted April 28, 2010 Try changing: else { print "\t</form>\n"; } to: print "\t</form>\n"; Quote Link to comment Share on other sites More sharing options...
MannyG Posted April 28, 2010 Author Share Posted April 28, 2010 Try changing: else { print "\t</form>\n"; } to: print "\t</form>\n"; didnt change anything... Quote Link to comment Share on other sites More sharing options...
MannyG Posted April 29, 2010 Author Share Posted April 29, 2010 still need help... 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.