ilikephp Posted January 2, 2011 Share Posted January 2, 2011 Hello! I have this code that creates dependent combo box How can I add: Select option" before the user selects option 2a, 2b or 2c "select option" should have no value Thank you, <html> <head> <title>Dependent Combo Boxes</title> </head> <body> <script type='text/javascript'> function update(a) { if(a==1) { document.getElementById("destination").innerHTML="<select name='combo2'><option>option 1 a</option><option>option 1b</option><option>option 1c</option></select>"; } if(a==2) { document.getElementById("destination").innerHTML="<select name='combo2'><option>option 2 a</option><option>option 2b</option><option>option 2c</option></select>"; } if(a==3) { document.getElementById("destination").innerHTML="<select name='combo2'><option>option 3 a</option><option>option 3b</option><option>option 3c</option></select>"; } } </script> <form name='form1'> <table> <tr><td><select name='combo1' onchange='update(this.value)'> <option value='1'>option 1</option> <option value='2'>option 2</option> <option value='3'>option 3</option> </select> </td></tr> <tr><td> <span id='destination'> <select name='combo2' disabled='disabled' > <option>Select combo 1 first</option> </select> </span> </td></tr> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/223206-combo-box/ 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.