M.O.S. Studios Posted October 27, 2008 Share Posted October 27, 2008 hey guys, basicly i have this code on my site <form name="shipform" action="test.php" method="GET"> <select name="ship_con" onChange="updateship_pro(this.selectedIndex)"> <option value="">Please select</option> <option value="Canada">Canada</option> <option value="U.S.A.">USA</option> </select> <select name="ship_pro"> </select> <input type="submit" Value="test"> </form> <script type="text/javascript"> var ship_conlist=document.shipform.ship_con var ship_prolist=document.shipform.ship_pro var ship_pro=new Array() ship_pro[0]="" ship_pro[1]=["Ontario|ON", "Quebec|QC", "Nova Scotia|NS", "New Brunswick|NB", "Manitoba|MB", "British Columbia|BC", "Prince Edward Island|PE", "Saskatchewan|SK", "Alberta|AB", "Newfoundland and Labrador|NU", "Yukon|YT"] ship_pro[2]=["state1|state1", "state2|state2"] function updateship_pro(selectedship_pro){ ship_prolist.options.length=0 for (i=0; i<ship_pro[selectedship_pro].length; i++) ship_prolist.options[ship_prolist.options.length]=new Option(ship_pro[selectedship_pro][i].split("|")[0], ship_pro[selectedship_pro][i].split("|")[1]) } </script> i would like to have the 3 <input type="text"> on this same form, 2 of them apear if ship_con = canada and only the 3rd if ship_con = U.S.A any ideas? Link to comment https://forums.phpfreaks.com/topic/130236-solved-dynamic-table-for-canda-and-us-shipping-info/ Share on other sites More sharing options...
Psycho Posted October 28, 2008 Share Posted October 28, 2008 <html> <head> <script type="text/javascript"> var ship_pro=new Array() ship_pro[0]='' ship_pro[1]=['Ontario|ON', 'Quebec|QC', 'Nova Scotia|NS', 'New Brunswick|NB', 'Manitoba|MB', 'British Columbia|BC', 'Prince Edward Island|PE', 'Saskatchewan|SK', 'Alberta|AB', 'Newfoundland and Labrador|NU', 'Yukon|YT'] ship_pro[2]=['state1|state1', 'state2|state2'] function updateship_pro(selectedship_pro) { var ship_prolist=document.shipform.ship_pro; ship_prolist.options.length = 0; for (var i=0; i<ship_pro[selectedship_pro].length; i++) { option = ship_pro[selectedship_pro][i].split('|'); ship_prolist.options[ship_prolist.options.length] = new Option(option[0], option[1]); } document.getElementById('address_fields').style.visibility = (selectedship_pro==0) ? 'hidden' : ''; document.getElementById('addr_3').style.visibility = (selectedship_pro!=2) ? 'hidden' : ''; } </script> </head> <body> <form name="shipform" action="test.php" method="GET"> <select name="ship_con" onChange="updateship_pro(this.selectedIndex)"> <option value="">Please select</option> <option value="Canada">Canada</option> <option value="U.S.A.">USA</option> </select><br> <span id="address_fields" style="visibility:hidden;"> <select name="ship_pro"></select><br> Address Line 1: <input type="text" name="line1"><br> Address Line 2: <input type="text" name="line2"><br> <span id="addr_3" style="visibility:hidden;">Address Line 3: <input type="text" name="line3"></span><br> </span> <input type="submit" Value="test"> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/130236-solved-dynamic-table-for-canda-and-us-shipping-info/#findComment-676310 Share on other sites More sharing options...
M.O.S. Studios Posted October 29, 2008 Author Share Posted October 29, 2008 Thanks i have it up and working Link to comment https://forums.phpfreaks.com/topic/130236-solved-dynamic-table-for-canda-and-us-shipping-info/#findComment-677221 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.