Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown items not visible after jquery show and hide

Status
Not open for further replies.

tshad

Programmer
Jul 15, 2004
386
0
0
US
I have a dropdownlist that is filled with items.

I show and hide the div surrounding the dropdownlist using the following code .

divPCSelection.Style.Add("display", bo.User ? "none" : "normal");

This hides and show fine.

When I do a post back and look at the pages view source, the div shows the style display:none. The dropdown also shows all the items in the dropdown.

If then do a jquery "show" of the div, the div shows but the dropdown is now empty.

The jquery code is:
Code:
function TogglePCSelection() {
         if ($("#<%=chkUser.ClientID%>").is(":checked")) {
            $("#<%=divPCSelection.ClientID%>").hide();
         }
         else {
            $("#<%=divPCSelection.ClientID%>").show();
         }
      }

It doesn't seem to actually be empty as I can do a normal postback and the data is now back in the dropdownlist.

What is happening here?

Thanks,

Tom


 
normal" is not a valid option for "display", use inline or block.

Start to debug. First, remove that code and have the ddl always show when the page loads so you can be sure the ddl has items.
Then, test your javascript/jquerycode by checking and unchecking the checkbox to make sure the show/hide works correctly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top