5

I'm designing an html page for WiFi authentication and I would like to introduce in this page a Checkbox and Submit button, upon reading the Terms and Condition and Checking the CheckBox, the Submit button will be active.

Is this doable?

thanks,

user3239387
  • 53
  • 1
  • 1
  • 4
  • Of Course its Doable .. Look into Javascript ..
    http://stackoverflow.com/questions/8394562/how-do-i-disable-and-re-enable-a-button-in-with-javascript
    – spetzz Feb 03 '14 at 09:38
  • Are you using any JS framework ? Anyway I think you shoud search google for this and found millions of answers ^^ – Nicolas Feb 03 '14 at 09:39
  • Hello, not I'm not using any JS.. it's only html code – user3239387 Feb 03 '14 at 09:41
  • The link you provided it doesn't work... nothing it shows in the HTML page :) – user3239387 Feb 03 '14 at 09:44
  • I have tried all of this, non of them are working:( – user3239387 Feb 03 '14 at 09:49
  • – user3239387 Feb 03 '14 at 09:50

1 Answers1

12
<html>
<head>
<script>
 function disableSubmit() {
  document.getElementById("submit").disabled = true;
 }

  function activateButton(element) {

      if(element.checked) {
        document.getElementById("submit").disabled = false;
       }
       else  {
        document.getElementById("submit").disabled = true;
      }

  }
</script>
</head>

<body onload="disableSubmit()">
 <input type="checkbox" name="terms" id="terms" onchange="activateButton(this)">  I Agree Terms & Coditions
<br><br>
  <input type="submit" name="submit" id="submit">
</body>
</html>
  • Thank you very much for your fast response, yes this is what I'm intended to do.. highly appreciated your efforts. – user3239387 Feb 03 '14 at 10:02
  • Hello, I have noticed the button is enabled as soon as the page loaded... it will be disabled only upon clicking/activating the CheckBox... – user3239387 Feb 03 '14 at 10:23
  • So you want the checkbox will be checked when the page is loaded. right? – Butchi Reddy Velagala Feb 03 '14 at 10:30
  • when the page is loaded the checkbox should be unchecked and the submit button should be disabled as well. do you want me to share the whole code with you? – user3239387 Feb 03 '14 at 10:32
  • Thats what we are doing. right? Share me the code So that i can do modifications directly. – Butchi Reddy Velagala Feb 03 '14 at 10:33
  • Hi, please find link below.. https://www.wetransfer.com/downloads/a436182ad4e7ddbb78dc6b7a220fcaa820140203103742/9991b050cf31f164a08e7ca144308ac320140203103742/7cbaf2 – user3239387 Feb 03 '14 at 10:39
  • Add the following line in your loadAction() function (at line 78 in your code). It will work. document.getElementById("submit").disabled = true; – Butchi Reddy Velagala Feb 03 '14 at 10:54
  • I have added it, but still it doesn't work.. } document.getElementById("submit").disabled = true; function loadAction(){ var url = window.location.href; var args = new Object(); var query = location.search.substring(1); var pairs = query.split("&"); for(var i=0;i – user3239387 Feb 03 '14 at 13:40
  • That line should be the first line in that function (not outside). I'm sharing the file, copy and save it as html file. http://vbreddy.my3gb.com/testform.txt – Butchi Reddy Velagala Feb 03 '14 at 13:48
  • Yes, this works pefectly. I hope once I upload it to the WLC it will works fine. Appreciate your effort and forgive me as I'm not script-er or html coder :) – user3239387 Feb 03 '14 at 13:53