creek16 Posted June 29, 2011 Share Posted June 29, 2011 Hello Guys. I'm getting confuse with <select> This is my first select <select name"selclassname"> <option ><center>- - - Class - - -</center></option> <?php $classresult = mysql_query("Select * from tblclasstype ORDER BY class_description"); while($classrow = mysql_fetch_array($classresult)) { echo "<option>" .$classrow['class_description']. "</option>"; } ?> </select> Now how do I get the value of the selected index which I will use in the next <select> for the query. My second <select> <select name"seltypename"> <option ><center>- - - Type - - -</center></option> <?php $typeresult = mysql_query("Select * from tblassettype WHERE asset_class = $SelectedIndexFrom1stSelect ORDER BY type_description"); while($typerow = mysql_fetch_array($typeresult)) { echo "<option>" .$typerow['type_description']. "</option>"; } ?> </select> Note that this is in the same page which no submit button will be executed. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/240675-help-with-fillin-up-from-db/ Share on other sites More sharing options...
Pikachu2000 Posted June 29, 2011 Share Posted June 29, 2011 Moving thread to AJAX help . . . Quote Link to comment https://forums.phpfreaks.com/topic/240675-help-with-fillin-up-from-db/#findComment-1236145 Share on other sites More sharing options...
Adam Posted June 29, 2011 Share Posted June 29, 2011 You can access the select box value through the DOM tree using: document.formName.selectName.value You'll need to assign the "onchange" event to the select box too, so that you can capture the value as they change it. One thing to note is that you're not correctly assigning the value of each option; you should use the "value" attribute. Browsers default to using the option text instead though, so you're code will still work. Quote Link to comment https://forums.phpfreaks.com/topic/240675-help-with-fillin-up-from-db/#findComment-1236192 Share on other sites More sharing options...
craygo Posted July 7, 2011 Share Posted July 7, 2011 You should try Barands Baaselect. It creates linked select boxes using ajax. can find it here http://www.phpclasses.org/package/1637-PHP-Generate-dynamically-linked-select-inputs.html may need to sign up to download it but it is free and the site has alot of classes. Quote Link to comment https://forums.phpfreaks.com/topic/240675-help-with-fillin-up-from-db/#findComment-1239577 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.