HTML checkbox & Submit Button by Agreeing on Terms and Condition
Asked Answered
K

1

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,

Knackwurst answered 3/2, 2014 at 9:33 Comment(6)
Of Course its Doable .. Look into Javascript .. <br> #8395062Mischief
Are you using any JS framework ? Anyway I think you shoud search google for this and found millions of answers ^^Janeth
Hello, not I'm not using any JS.. it's only html codeKnackwurst
The link you provided it doesn't work... nothing it shows in the HTML page :)Knackwurst
I have tried all of this, non of them are working:(Knackwurst
<script> function checkusers() { var a = document.getElementById(checkbox).value; if(a ==0) { document.getElementById(add_button").disabled = false; } else { document.getElementById(add_button).disabled = true; } } </script>Knackwurst
C
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 & Conditions
  <input type="submit" name="submit" id="submit">
</body>
</html>
Casualty answered 3/2, 2014 at 9:56 Comment(10)
Thank you very much for your fast response, yes this is what I'm intended to do.. highly appreciated your efforts.Knackwurst
Hello, I have noticed the button is enabled as soon as the page loaded... it will be disabled only upon clicking/activating the CheckBox...Knackwurst
So you want the checkbox will be checked when the page is loaded. right?Casualty
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?Knackwurst
Thats what we are doing. right? Share me the code So that i can do modifications directly.Casualty
Hi, please find link below.. wetransfer.com/downloads/…Knackwurst
Add the following line in your loadAction() function (at line 78 in your code). It will work. document.getElementById("submit").disabled = true;Casualty
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<pairs.length;i++){ var pos = pairs[i].indexOf('='); if(pos == -1) continue; var argname = pairs[i].substring(0,pos); var value = pairs[i].substring(pos+1); args[argname] = unescape(value); }Knackwurst
That line should be the first line in that function (not outside). I'm sharing the file, copy and save it as html file. vbreddy.my3gb.com/testform.txtCasualty
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 :)Knackwurst

© 2022 - 2024 — McMap. All rights reserved.