You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Velarde, Domonic R. - WMD" <Do...@ci.denver.co.us> on 2005/09/08 16:39:56 UTC

disable the submit button

Sorry for posting this twice, but a lot of activity here yesterday.
Hoping someone will see this the second time around.

 

I need to disable the submit button after a user presses it.  I have
found some examples how to do this.  Some more complicated than others.

 

I am opting to go for the simpler solution and use JavaScript to disable
the submit button after the user presses it.  Can any one show what the
JavaScript looks like?  I found many reference to how but when
attempting it does not work. The page hangs. Here is sample code of what
I have been trying:

 

 <input type="submit" jwcid="@Submit" value="message:button-proceed"
listener="ognl:listeners.submit" onClick="this.disabled=true;"/>

 

It will grey out the button, which is what I want, but then it hangs
does and does not go to the next page.

 

Any help much appreciated.

 

 

 


Re: disable the submit button

Posted by Jesse Kuhnert <jk...@gmail.com>.
What you need I think would be easily solved by taking a look at the 
org.apache.tapestry.form.Form.js library file.

To get the desired result you could add this javascript to your page:

Tapestry.onsubmit("yourFormElementId", yourFunctionName);

You need this to happen in the initialization section of your page, or else 
the Tapestry form wrapper object may not exist yet when it gets exectured, 
so more than likely you will need to create a .script file to handle your 
new form semantics. In that scenerio you could add a section in your 
<initialization> element that looks sort of like:

<body>
function disableSubmitButton() {
var submitElement = Tapestry.find('${submitButtonNameOrId}');
submitElement.disabled = true;
}
</body>
<initialization>
Tapestry.onsubmit('${formId}', disableSubmitButton);
</initialization>

The call to Tapestry.onsubmit adds a "handler" into the tapestry form submit 
javascript pipeline, causing the method name you passed in to be called 
during the forms submission. The ${formId} sort of semantics are covered in 
the tapestry documentation on how to write javascript include pages. Hope 
this helps a little, you'll still have to do your homework to get your 
.script file created and then inserted into your page.

This is probably the hard solution, with an easier solution lurking out 
there by someone who knows better, but it's all I know for now so it will 
have to do until someone else responds. :(

jesse

On 9/8/05, Velarde, Domonic R. - WMD <Do...@ci.denver.co.us> 
wrote:
> 
> Sorry for posting this twice, but a lot of activity here yesterday.
> Hoping someone will see this the second time around.
> 
> 
> 
> I need to disable the submit button after a user presses it. I have
> found some examples how to do this. Some more complicated than others.
> 
> 
> 
> I am opting to go for the simpler solution and use JavaScript to disable
> the submit button after the user presses it. Can any one show what the
> JavaScript looks like? I found many reference to how but when
> attempting it does not work. The page hangs. Here is sample code of what
> I have been trying:
> 
> 
> 
> <input type="submit" jwcid="@Submit" value="message:button-proceed"
> listener="ognl:listeners.submit" onClick="this.disabled=true;"/>
> 
> 
> 
> It will grey out the button, which is what I want, but then it hangs
> does and does not go to the next page.
> 
> 
> 
> Any help much appreciated.
> 
> 
> 
> 
> 
> 
> 
> 
>

Re: disable the submit button

Posted by Paul Ferraro <pm...@columbia.edu>.
Unfortunately, disabling the submit button in this manner will prevent
your submit listener from being invoked since the value of the submit
button (like any disabled form component) is not submitted with the
form.  This value is looked for by the submit component to determine
whether or not to invoke its listener.  You might be able to get by with
using a form listener instead.

Paul

RWinter@boystown.com.au wrote:

>
>
>If you specify an onClick you also then need to submit the form usin
>javascript so your onCLick will become
>
>onClick="this.disabled=true; document.form1.submit();"
>
>where form1 is the name of your form.
>
>
>
>
>
>
>                                                                           
>             "Velarde, Domonic                                             
>             R. - WMD"                                                     
>             <Domonic.Velarde@                                          To 
>             ci.denver.co.us>          "Tapestry users"                    
>                                       <ta...@jakarta.apache.org>  
>             09/09/2005 00:39                                           cc 
>                                                                           
>                                                                   Subject 
>             Please respond to         disable the submit button           
>             "Tapestry users"                                              
>             <tapestry-user@ja                                             
>             karta.apache.org>                                             
>                                                                           
>                                                                           
>                                                                           
>
>
>
>
>Sorry for posting this twice, but a lot of activity here yesterday.
>Hoping someone will see this the second time around.
>
>
>
>I need to disable the submit button after a user presses it.  I have
>found some examples how to do this.  Some more complicated than others.
>
>
>
>I am opting to go for the simpler solution and use JavaScript to disable
>the submit button after the user presses it.  Can any one show what the
>JavaScript looks like?  I found many reference to how but when
>attempting it does not work. The page hangs. Here is sample code of what
>I have been trying:
>
>
>
> <input type="submit" jwcid="@Submit" value="message:button-proceed"
>listener="ognl:listeners.submit" onClick="this.disabled=true;"/>
>
>
>
>It will grey out the button, which is what I want, but then it hangs
>does and does not go to the next page.
>
>
>
>Any help much appreciated.
>
>
>
>
>
>
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>  
>


Re: disable the submit button

Posted by RW...@boystown.com.au.



If you specify an onClick you also then need to submit the form usin
javascript so your onCLick will become

onClick="this.disabled=true; document.form1.submit();"

where form1 is the name of your form.






                                                                           
             "Velarde, Domonic                                             
             R. - WMD"                                                     
             <Domonic.Velarde@                                          To 
             ci.denver.co.us>          "Tapestry users"                    
                                       <ta...@jakarta.apache.org>  
             09/09/2005 00:39                                           cc 
                                                                           
                                                                   Subject 
             Please respond to         disable the submit button           
             "Tapestry users"                                              
             <tapestry-user@ja                                             
             karta.apache.org>                                             
                                                                           
                                                                           
                                                                           




Sorry for posting this twice, but a lot of activity here yesterday.
Hoping someone will see this the second time around.



I need to disable the submit button after a user presses it.  I have
found some examples how to do this.  Some more complicated than others.



I am opting to go for the simpler solution and use JavaScript to disable
the submit button after the user presses it.  Can any one show what the
JavaScript looks like?  I found many reference to how but when
attempting it does not work. The page hangs. Here is sample code of what
I have been trying:



 <input type="submit" jwcid="@Submit" value="message:button-proceed"
listener="ognl:listeners.submit" onClick="this.disabled=true;"/>



It will grey out the button, which is what I want, but then it hangs
does and does not go to the next page.



Any help much appreciated.











---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org