M.O.S. Studios Posted October 27, 2008 Share Posted October 27, 2008 this is what im looking for drop down option 1 option 2 if user selects option 1 text boxs 1 & 2 shows if user selects option 2 text box 3 shows i reviewed my last question and relised it was to complicated so i simplified it thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/130243-solved-hide-show-with-drop-down/ Share on other sites More sharing options...
RichardRotterdam Posted October 27, 2008 Share Posted October 27, 2008 here is a start for you javascript function showBoxes(value){ if(value==1){ //show boxes 1 and 2 }else if(value==2){ //show box 3 } } html <select onchange="showBoxes(this.value)"> <option value="1">1</option> <option value="2">2</option> </select> Quote Link to comment https://forums.phpfreaks.com/topic/130243-solved-hide-show-with-drop-down/#findComment-675483 Share on other sites More sharing options...
M.O.S. Studios Posted October 27, 2008 Author Share Posted October 27, 2008 hey thanks, igot that to work, the only part im having trouble with now is that it shows all 3 boxes when the page is loaded im trying to get the function to run with onLoad but it dosn't seem to work. any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/130243-solved-hide-show-with-drop-down/#findComment-675878 Share on other sites More sharing options...
M.O.S. Studios Posted October 27, 2008 Author Share Posted October 27, 2008 i got it this is the code <body onLoad="document.getElementById('ship_zip').style.display='none';"> <script type="text/javascript"> function ChangeDropdowns(value){ if(value=="U.S.A."){ document.getElementById('ship_post1').style.display='none'; document.getElementById('ship_post2').style.display='none'; document.getElementById('ship_zip').style.display='block'; }else{ document.getElementById('ship_post1').style.display='block'; document.getElementById('ship_post2').style.display='block'; document.getElementById('ship_zip').style.display='none'; } } </script> <form> <select id="abonnement" name="abonnement" onchange="ChangeDropdowns(this.value);"> <option value="Canada">Canada</option> <option value="U.S.A.">U.S.A.</option> </select> <input type=text id="ship_post1" name="ship_post1" value="1"> <input type=text id="ship_post2" name="ship_post2" value="2"> <input type=text id="ship_zip" name="ship_zip"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/130243-solved-hide-show-with-drop-down/#findComment-675891 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.