Home > Archive > PHP Pear > January 2007 > Re: [PEAR] [QUICKFORM] checkbox required for enable submit button
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PEAR] [QUICKFORM] checkbox required for enable submit button
|
|
| Luca Giandoso 2007-01-15, 4:02 am |
| I don't understand your problem. Why can't you simply add some
javascript code, like the one you posted (but it could be simpler) to
quickform checkbox element?
On 1/15/07, Marco Sottana <marco.sottana@q-web.it> wrote:
> like "accept terms"
> code:
> <script>
>
> //"Accept terms" form submission- By Dynamic Drive
> //For full source code and more DHTML scripts, visit
> http://www.dynamicdrive.com
> //This credit MUST stay intact for use
>
> var checkobj
>
> function agreesubmit(el){
> checkobj=el
> if (document.all||document.getElementById){
> for (i=0;i<checkobj.form.length;i++){ //hunt down submit button
> var tempobj=checkobj.form.elements[i]
> if(tempobj.type.toLowerCase()=="submit")
> tempobj.disabled=!checkobj.checked
> }
> }
> }
>
> function defaultagree(el){
> if (!document.all&&!document.getElementById){
> if (window.checkobj&&checkobj.checked)
> return true
> else{
> alert("Please read/accept terms to submit form")
> return false
> }
> }
> }
>
> </script>
>
> </head>
> <body >
> <br /><br />
> <div align="center">
>
>
> <form name="agreeform" onSubmit="return defaultagree(this)" action="">
> <textarea class="codecontainer" rows="8" name="S1" cols="45"
> wrap="virtual">Accetta le condizioni</textarea><br>
> <input name="agreecheck" type="checkbox"
> onClick="agreesubmit(this)"><b>Accetto</b><br>
> <input type="Submit" value="Submit!" disabled>
> </form>
>
> <script>
> //change two names below to your form's names
> document.forms.agreeform.agreecheck.checked=false
> </script>
>
>
>
>
> ----- Original Message -----
> From: "Marco Sottana" <marco.sottana@q-web.it>
> To: <pear-general@lists.php.net>
> Sent: Monday, January 15, 2007 9:13 AM
> Subject: [PEAR] [QUICKFORM] checkbox required for enable submit button
>
>
> hi, i would like to add a checkbox that enable if checked, and disable if
> unchecked the submit button
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
| |
| Marco Sottana 2007-01-15, 8:01 am |
| like this ? do you suggest any optimize ?
code:
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function enableSubmit(checkobj){
var f=document.getElementById("idsubmit");
f.disabled=!checkobj.checked;
}
//-->
</SCRIPT>
<?php
// Load the main class
require_once 'HTML/QuickForm.php';
$form = new HTML_QuickForm('firstForm');
$el = &HTML_QuickForm::createElement("textarea", "a","b",null);
$form->addElement($el);
$form->addElement('checkbox', 'nomecheckbox', 'Accept terms',
"Yes",array("onClick" => "enableSubmit(this); " ));
$form->addElement('submit', null,
'Send',array("id"=>"idsubmit","disabled"));
if ($form->validate()) {
$form->freeze();
}
echo $form->display();
----- Original Message -----
From: "Luca Giandoso" <luca.giandoso@gmail.com>
To: "Marco Sottana" <marco.sottana@q-web.it>
Cc: <pear-general@lists.php.net>
Sent: Monday, January 15, 2007 9:30 AM
Subject: Re: [PEAR] [QUICKFORM] checkbox required for enable submit button
>I don't understand your problem. Why can't you simply add some
> javascript code, like the one you posted (but it could be simpler) to
> quickform checkbox element?
>
> On 1/15/07, Marco Sottana <marco.sottana@q-web.it> wrote:
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
|
|
|
|
|