I am making an functionality where on click of button a textbox should appear, and whatever the user fills the value , it should automatically gets updated in that dropdown. I tried with the below mentioned code, where I am hiding/showing the textbox but unable to fill the dropdown:
<script type="text/javascript">
$(document).ready(function () {
$('#ctl00_ContentPlaceHolder1_txtOtherBusiness').hide();
$("#ctl00_ContentPlaceHolder1_btnbusinessAdd").click(function () {
$('#ctl00_ContentPlaceHolder1_txtOtherBusiness').show();
});
$("#ctl00_ContentPlaceHolder1_btnbusinessAdd").click(function () {
$('#ctl00_ContentPlaceHolder1_txtOtherBusiness').hide();
});
})
</script>
Also see the html for dropdown, textbox and button :-
<td>
<asp:DropDownList CssClass="txtfld-popup" ID="ddlBusinessUnit" runat="server"></asp:DropDownList>
<asp:Button ID="btnbusinessAdd" runat="server" Width="63" Text="Add" CausesValidation="false"/>
<asp:TextBox ID="txtOtherBusiness" runat="server" Visible="true" CssClass="txtfld-popup" CausesValidation="false"></asp:TextBox>
<asp:RequiredFieldValidator CssClass="error_msg" ID="reqBusinessUnit" ControlToValidate="ddlBusinessUnit" runat="server" ErrorMessage="Please enter business unit" InitialValue="--Select--" SetFocusOnError="true"></asp:RequiredFieldValidator>
</td>