Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
146
rated 0 times [  153] [ 7]  / answers: 1 / hits: 100224  / 9 Years ago, wed, july 29, 2015, 12:00:00

I have code like this at the bottom of my form.



<p>
<input type=checkbox id=agreed>
I agree to keep my Username and Password confidential and uphold
the integrity of this pharmacy
</p>
<input type=submit id=submit disabled class=formbutton button-primary value=Go>


I want this a listener in JavaScript to be able to enable the submit button.
I know it might be wrong or something but my JavaScript looks sort of like this



function track() {
if ( document.getElementById(agreed).checked==true ) {
document.getElementById(submit).removeAttribute(disabled);
} else {
document.getElementById(agreed).checked==false
}
};

More From » html

 Answers
47

You can do this for the input:



<input type='checkbox' onchange='handleChange(this);'>Checkbox


And this for enabling the button:



function handleChange(checkbox) {
if(checkbox.checked == true){
document.getElementById(submit).removeAttribute(disabled);
}else{
document.getElementById(submit).setAttribute(disabled, disabled);
}
}

[#65618] Tuesday, July 28, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aleighabayleef

Total Points: 511
Total Questions: 99
Total Answers: 99

Location: Aruba
Member since Fri, Jun 24, 2022
2 Years ago
aleighabayleef questions
Fri, Jun 5, 20, 00:00, 4 Years ago
Thu, Jun 4, 20, 00:00, 4 Years ago
Sat, Sep 21, 19, 00:00, 5 Years ago
Thu, Jul 18, 19, 00:00, 5 Years ago
;