Multi drop-down menu
Posted: Wed Apr 28, 2010 4:16 pm
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...
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!
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...
Code: Select all
<?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";
}
?>
Any help is greatly appreciated, thank you!