Get & set drop down value using jQuery.
Posted
by Muhammad Sajid
on Stack Overflow
See other posts from Stack Overflow
or by Muhammad Sajid
Published on 2010-05-10T15:20:35Z
Indexed on
2010/05/10
15:24 UTC
Read the original article
Hit count: 169
If user select an option from dropdown it will shown it a textbox but if he select option having value "Other" then a row will appear to type value for other.
my code works fine except when option value is not equal to "Other"
<script type="text/javascript"><!--
function setAndReset(box) {
if(box.value == 'Other'){
$("#ShowHide").hide();
}
document.FormName.hiddenInput.value = box.value;
}
//-->
</script>
<body bgcolor="#ffffff">
<form id="FormName" action="" method="get" name="FormName">
<select name="choice1" size="1" onchange="setAndReset(this);">
<option value="one">first</option>
<option value="two">second</option>
<option value="three">third</option>
<option value="other">Other</option>
</select>
<input type="text" name="hiddenInput" value="">
<tablt><tr id="ShowHide"><td>
<input type="text" name="otherInput">
</td></tr></table>
<input type="submit" name="submitButtonName">
</form>
</body>
but it does not show/hide & does not set value in textbox.
If it's solve using jquery then i will be thankful to you for you code.
Thanks.
© Stack Overflow or respective owner