?
Solved

asp.net, c# using a checkbox to hid a <div> but initial page shows <div>  even with checkbox unchecked

Posted on 2012-09-20
3
Medium Priority
?
1,065 Views
Last Modified: 2012-09-20
I am using this checkbox to show/hide a <div>  in my aspx form.

My checkbox
<asp:CheckBox ID="cbGuest1" Text="Guest 1" onclick="showMe('Guest1Div', this)" CssClass="crimson" Checked="False" class="style59"  runat="server" /> 

Open in new window

 
Javascript
<script type="text/javascript" language="javascript">
    function showMe(it, box) {
        var vis = (box.checked) ? "block" : "none";
        document.getElementById(it).style.display = vis;
    }</script>

Open in new window


The issue is that the page loads with the checkbox unchecked, but the <div> still shows.  It does not hide until I check the box, then uncheck it again.  How can I hide the <div> onload?

Thanks.
0
Comment
Question by:javierpdx
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 38419520
use css :
#Guest1Div {
       display:none;
}

Open in new window

0
 

Author Closing Comment

by:javierpdx
ID: 38419530
Thanks!  I appreciate the help.
0
 
LVL 83

Expert Comment

by:leakim971
ID: 38419536
you're welcome!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question