Web Analytics Made Easy -
StatCounter Javascript Checkbox Confirm - CodingForum

Announcement

Collapse
No announcement yet.

Javascript Checkbox Confirm

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript Checkbox Confirm

    Hello,

    I'm new to Javascript, but have been programming in PHP and other web codes for 4 years now.

    I was wondering how you would check if a checkbox was ticked, upon its selection and then unhide HTML content, and then hide such content when deselected..

    So far I have this:

    Code:
    <script type="text/javascript">
    	function Agree() {
    		document.getElementById("stepTwo").className = "";
    	}
    </script>
    Which is called by onclick="Agree()" on the select box itself..

    I understand an if statement is needed, but how would one go about doing this as my if statements do not appear to be working.

  • #2
    something like...

    Code:
    if (document.getElementById("mycheckbox").checked == true) {
    document.getElementById("stepTwo").style.display="inline";
    } else {
    document.getElementById("stepTwo").style.display="none";
    }

    Comment

    Working...
    X