See here for another one like this Hide/show div on dropdown value
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> <select name="CallBackTime" id="CallBackTime"> <option selected="selected">Same or different</option> <option value="same">Same</option> <option value="different">Different</option> </select> <input type="text" name="name" id="name" value="Please add" /> <script> $('#CallBackTime').change(function() { var dog = $(this).val() if (dog=="same") { $("#name").hide(); } if (dog=="different") { $("#name").show(); } }); </script> |
To hide with out losing the position or it collapsing use this :-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<script> $('#CallBackTime').change(function() { var dog = $(this).val() if (dog=="same") { $("#name").animate({opacity:0}); } if (dog=="different") { $("#name").animate({opacity:1}); } }); </script> |
Hide selected option when dropdown is opened
Show hide form depending on value of dropdown