Menu

Hide or Show textbox on dropdown onchange event

you will easy to Hide or Show textbox on dropdown onchange event.
Following two Step:
First Step: to create java script function

Download Source code:=>HideorShowTextboxInDropdownOnchangeEvent.rar
 

function HideTextBox(ddlId)
{
var ddlControl = document.getElementById(ddlId.id);
var Text = ddlControl.options[ddlControl.selectedIndex].text;
//it depends on which text Selection do u want to hide or show your textbox
if (Text == 'Test1')
{
document.getElementById('<%= txtDemo.ClientID %>').style.display = 'none';

}
else
{
document.getElementById('<%= txtDemo.ClientID %>').style.display = '';
}
}

Second Step: Html Code

<asp:DropDownList ID="drop1" runat="server" onchange="HideTextBox(this);">
<asp:ListItem Value="0" Text="Test"></asp:ListItem>
<asp:ListItem Value="1" Text="Test1"></asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="txtDemo" runat="server"></asp:TextBox>

No comments

Leave a Reply


3 + 7 =

Categories