SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2012
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Javascript - very simple checkbox onclick code not working - any help please???

    Hello folks,

    I have a content form. It has a textbox and a checkbox control (both are asp server controls and not HTML).

    When the user checks on the checkbox control, the textbox control has to become invisible. If unchecked the textbox control has to become visible. The following code works on a regular webform (meaning not as a content form). toggleVisibility is the function name that does the actual work. I am guessing I am not passing the textbox control ID properly to toggleVisibility function. Can someone guide me please?

    Following is the code:
    Code:
     
    <asp:TextBox ID="TextBoxPeriod" 
            runat="server"  Width="97px"></asp:TextBox>
    
    <asp:CheckBox ID="CheckBoxFromArchive"  runat="server" Visible="true" 
               Onclick="toggleVisibility('<%=TextBoxPeriod.ClientID %>');"  />
    
     function toggleVisibility(controlId) {
            var control = document.getElementById(controlId);
    
            
            if (control.style.visibility == "visible" || control.style.visibility == "") {
                control.style.visibility = "hidden";
                
            }
    
            else {
                control.style.visibility = "visible";
                
            }
    
    
    
        }
    Thanks much
    nath

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Location
    Bs. As. - Argentina
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think that seen the resultant code that goes to the browser, not the sever code, will be a easier way to find out what's is not working in so simply task.

    See you


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •