Set checkbox always unchecked
| From: | Stelio Gouveia | Date: | Wed, 03 May 2006 13:03:14 +0000 |
| Subject: | Set checkbox always unchecked | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-23915@lists.php.net to get a copy of this message | ||
Quickforms question: i don't want quickforms to "remember" a certain
form element when rules arent met
Basically heres the scenario:
Ive got a form that takes a number of required fields.
When a user submits the form and some rules aren't met, then the user
will get the same form again but this time the form remembers what form
elements where changed.
Now all this is fine, actually its perfect.
The catch is this, my submit button is disabled on every form until the
user checks my "agree checkbox".
So let me iterate, user clicks checkbox and submit button is enabled,
then the user clicks the submit button. But now some of the rules
haven't been met.
So the checkbox is still checked and the submit button is disabled. So
the user have to uncheck and re-check the checkbox to enable the submit
button.
Whats my question again...
How do i get quickforms to NOT "remember" if the checkbox was checked
after validation rules not met (form elements changed)...
anyone trying to achieve this, heres some basic code:
Javascript:
----------
function enablebutton() {
if(document.frmSignUp.agree.checked) {
document.frmSignUp.submit.disabled=false;
}
else {
document.frmSignUp.submit.disabled=true;
}
}
PHP:
-----
$form = new HTML_QuickForm('frmSignUp', null, 'signup.php');
$form->addElement('checkbox', 'agree', null, 'I agree');
$form->createElement('submit', 'submit', 'submit',
'disabled');
$form->display();