HTML Form check box IF Statement (show/hide)

Posted on 2007-07-26
Last Modified: 2008-01-09
I have a simple html form being sent from web to email.

I need to hide the submit button until the I Accept button has been clicked... I can do it in theory but for some reason my I'm not with it today and can't seem to get it right :(

I assume I would start by having the submit button Hidden, and then make it visable once the checkbox has been clicked?

Any help appreciated
Question by:Kegan5
    LVL 14

    Accepted Solution

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


                <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
                <title>Untitled Page</title>
                <script type="text/javascript"><!--
    function setSubmit() {
          if (document.agreement.radiobutton1[0].checked) {
                document.agreement.submitbutton.disabled = false;
          } else {
                document.agreement.submitbutton.disabled = true;

    window.onload = function() {
                document.agreement.submitbutton.disabled = true;

          <body bgcolor="#ffffff">
                <form action="requestform.html" method="post" name="agreement">
                      <p><label><input type="radio" name="radiobutton1" value="submitbutton" onclick="setSubmit();">
            I accept the terms and conditions<br>
                            <label>        </label>
            <label><input type="radio" name="radiobutton1" value="canelbutton" checked onclick="setSubmit();">        
                            I <strong>DO NOT</strong> </label>
                            accept these terms and conditions<br>
                            <input type="submit" name="submitbutton" value="Submit">
              <input id="cancel" type="reset" name="cancel" value="Cancel" onclick="window.location=''"></p>

    LVL 14

    Expert Comment

    Use of RADIO button for I AGREE/DISGREE is a better option than BUTTON.

    Author Comment

    I did have radio buttons with Agree / Disagree but it means having to read each one with disagree and delete the emails. Which would be tedious :)

    I've tried your code above it seems to open up the new mail but doesnt add a field for Agreement, it just doesnt say anything at all.

    Is there away to alert the user maybe with a message box asking them to click the button?


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Adobe Dreamweaver CC 2015

    Adobe Dreamweaver Creative Cloud is used by web designers and front-end developers and allows you to visualize your site in real-time as you code. This course covers exam objectives for the Adobe Certified Associate (ACA) certification.

    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now