Show textbox on change of dropdown and selected value is other
State dropdown have list of states with last item OTHER, so if user selects "OTHER" then a textbox should be displayed.
If user selects any state: 1. don't show text box 2. if already displayed, hide that
If user selects OTHER only then textbox should be displayed.
2 Answers
Adjust your HTML like this
<asp:DropDownList ID="ddlProducts" runat="server"
onchange="ShowHideOther(this, 'divOther');"/>
<div id="divOther" style="display:none">
<asp:TextBox ID="txtOther" runat="server" />
</div>
<script>
function ShowHideOther(ddl, other)
{
if(ddl.value == "OTHER")
document.getElementById(other).style.display = "block";
else
document.getElementById(other).style.display = "none";
}
</script>
|
1
|
Answered:
02 Mar 2013
Reputation: 1,880
|
|
try this by using jQyery:
$("#TextBoxID").hide();
$("#DropdownID").change(function(){
if ($(this).val() === "YOURVALUE")
$("#TextBoxID").show();
else
$("#TextBoxID").hide();
});
|
1
|
Answered:
02 Mar 2013
Reputation: 52
|
|
This week users
