ilikephp Posted January 16, 2011 Share Posted January 16, 2011 Hi, I have this code below, it is working fine, but I need to put it 3 times in my form, what should I do in order to keep the second and the third time script independent from each other. Thank you, <html> <body> <script type='text/javascript'> function update(a) { if(a=='1' || a=='2') { document.getElementById("destination").innerHTML="<select name='combo2'><option>option A</option><option>Option B</option></select>"; } } </script> <form name='form1'> <table> <tr> <td><select name='combo1' onChange='update(this.value)'> <option value="" selected>Select</option> <option value="1">1</option> <option value="2">2</option> </select></td> </tr> <tr><td> <span id='destination'> <select name='combo2' disabled='disabled' > <option selected>Select combo 1 first</option> </select> </span> </td></tr> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/224620-dependent-drop-down-list/ Share on other sites More sharing options...
Omirion Posted January 16, 2011 Share Posted January 16, 2011 What do you mean by independent? Quote Link to comment https://forums.phpfreaks.com/topic/224620-dependent-drop-down-list/#findComment-1160285 Share on other sites More sharing options...
ilikephp Posted January 16, 2011 Author Share Posted January 16, 2011 When I choose option 1, the other field will be enabled; I need to re-put the same fields twice in the same form like: Select Combo 1 first Select Combo 1 first Select Combo 1 first the problem is when I choose select in line 2 "the combo 1 first" of the first line will change Quote Link to comment https://forums.phpfreaks.com/topic/224620-dependent-drop-down-list/#findComment-1160289 Share on other sites More sharing options...
Omirion Posted January 16, 2011 Share Posted January 16, 2011 Sorry it's probably a language barrier cause i still can't understand what the outcome should be. Basicly when you select something from the first opteions, being '1' and '2' the second select will be enabled. From then on you want to do what exactly. Quote Link to comment https://forums.phpfreaks.com/topic/224620-dependent-drop-down-list/#findComment-1160298 Share on other sites More sharing options...
ilikephp Posted January 16, 2011 Author Share Posted January 16, 2011 this is the code: <html> <body> <script type='text/javascript'> function update1(a) { if(a=='1' || a=='2') { document.getElementById("destination").innerHTML="<select name='combo2'><option>option A</option><option>Option B</option></select>"; } } </script> <form name='form1'> <table> <p>First:</p> <tr> <td><select name='combo1' onChange='update1(this.value)'> <option value="" selected>Select</option> <option value="1">1</option> <option value="2">2</option> </select></td> </tr> <tr><td> <p><span id='destination'> <select name='combo2' disabled='disabled' > <option selected>Select combo 1 first</option> </select> </span></p> <p><script type='text/javascript'> function update2(a) { if(a=='1' || a=='2') { document.getElementById("destination2").innerHTML="<select name='combo4'><option>option A</option><option>Option B</option></select>"; } } </script></p> <p> </p> <p>Second</p> <p> </p> <p> <select name='combo3' onChange='update2(this.value)'> <option value="" selected>Select</option> <option value="1">1</option> <option value="2">2</option> </select> </p> <p> <span id='destination2'><select name='combo4' disabled='disabled' > <option selected>Select combo 1 first</option> </select></span> </p></td></tr> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/224620-dependent-drop-down-list/#findComment-1160312 Share on other sites More sharing options...
ilikephp Posted January 16, 2011 Author Share Posted January 16, 2011 I think it is fixed Quote Link to comment https://forums.phpfreaks.com/topic/224620-dependent-drop-down-list/#findComment-1160313 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.