i know this thing is too simple but how i show div on specific ListItem ?
my code is:
<asp:DropDownList ID="dropYesNo" runat="server">
<asp:ListItem Text="Choose..." Value="-1"></asp:ListItem>
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"></asp:ListItem>
</asp:DropDownList>
later on i have a div:
<div id="optional">
<p>Please Enter Your Reason</p></br>
<asp:TextBox ID="_refuse" runat="server" TextMode="MultiLine" />
</br>
</div>
this div CSS is hidden by default. i want that when the user chooses "No" on the drop down,the div will appear. i know it's usually done with JavaScript, but i didn't understand how to do it.
thank you.
P.S.
i have another little related question, if i have a table in my SQL db lets call it users, and it has name , id columns. how do i load the entire columns to drop down so if the user chooses a name the is it's id.
Using JQuery the hiding and showing of the Div is pretty straight forward:
The database aspect really depends on the platform you are using and would be done server side normally. You already know how to assign the Text and the Value attributes, Text = Name, Value = ID.
Could not the code be more simplified?
The markup
The javascript
If you are using jquery then
See example here.