HTML Form check box IF Statement (show/hide)

Posted on 2007-07-26
Medium Priority
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
  • 2
LVL 14

Accepted Solution

bugs021997 earned 200 total points
ID: 19573146
<!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='http://www.google.com/'"></p>

LVL 14

Expert Comment

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

Author Comment

ID: 19573180
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?


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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…
Suggested Courses

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