javascript - Show|Hide Div depending on show DropDownList -


i know thing simple how 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 have div:

<div id="optional">     <p>please enter reason</p></br>     <asp:textbox id="_refuse" runat="server" textmode="multiline" />     </br> </div> 

this div css hidden default. want when user chooses "no" on drop down,the div appear. know it's done javascript, didn't understand how it.

thank you.

p.s.

i have little related question, if have table in sql db lets call users, , has name , id columns. how load entire columns drop down if user chooses name it's id.

using jquery hiding , showing of div pretty straight forward:

$(function() {   $("#dropyesno").change(function() {     toggledropdown();   });   toggledropdown(); // done ensure correct hiding/showing on page reloads due validation errors });  function toggledropdown() {   if ($("#dropyesno").val() == "no") {     $("#optional").show();   } else {     $("#optional").hide();   } };  

the database aspect depends on platform using , done server side normally. know how assign text , value attributes, text = name, value = id.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -