hugl3 Posted June 2, 2008 Share Posted June 2, 2008 Hello everyone. I was reading this forum for a quit time. But now I registered, because came to the question - I can't solve myself. Maybe someone here could be of any help. Lets say I have a listbox - <select size=1 name="listweare"> <OPTION selected value="1">Female</OPTION> <OPTION value="2">Male</OPTION> </select> What I need to do, is: If the Female is selected in listbox; then show one more listbox to the right - Blonde/Brunette , the code woule be like: <select size=1 name="hairsyle"> <OPTION selected value="1">Blonde</OPTION> <OPTION value="2">Brunette</OPTION> </select> If I switch to Male, this listbox is beign hidden - is it possible to be done ? Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/108341-linked-listboxes-or-how-i-can-call-them/ Share on other sites More sharing options...
DarkWater Posted June 2, 2008 Share Posted June 2, 2008 Use Javascript or Ajax+PHP to do that. Quote Link to comment https://forums.phpfreaks.com/topic/108341-linked-listboxes-or-how-i-can-call-them/#findComment-555460 Share on other sites More sharing options...
hansford Posted June 2, 2008 Share Posted June 2, 2008 heres the javascript way. This is just the general idea of how its done using a hidden DIV <form name='form1'> <select size=1 name="listweare" onchange='javascript:checkit(this.form)'> <OPTION selected value="1">Male</OPTION> <OPTION value="2">Female</OPTION> </select> </form> <div id='list2' style="visibility: hidden"> <form name='form2'> <select size=1 name="hairsyle"> <OPTION selected value="1">Blonde</OPTION> <OPTION value="2">Brunette</OPTION> </select> </form> </div> <script> function checkit(f){ var box = f.listweare; var number = box.options[box.selectedIndex].value; if(number == 2){ el = document.getElementById('list2') el.style.visibility = 'visible'; } else{ el = document.getElementById('list2') el.style.visibility = 'hidden'; } } Quote Link to comment https://forums.phpfreaks.com/topic/108341-linked-listboxes-or-how-i-can-call-them/#findComment-555611 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.