When you submit a form via a submit button, the submit button's name and value are posted along with the form data. The Submit component relies on this information to determine whether or not to trigger its own listener. In HTML, when a form element is disabled, its name and value are not posted - the submit button is no different. You can achieve the same desired behavior without resorting to disabling the button by using either a javascript variable defined in the page to store the submitted state, or by commandeering one of the lesser known/used attributes of the button (e.g. title, lang, etc.).
e.g.
<input type="submit" onclick="if (!this.title) { this.title = 'Processing...'; return true } return false"/>


Of course, when using a method like this to prevent double submits, you can't prevent the user from clicking the stop button on their browser. After hitting the stop button, the user will be unable to submit the form again since you've effectively disabled the button. The only way around this is to refresh the page - but of course the user will any loose data they've typed into the form.

Paul

LOCHART,DOUGLAS E wrote:

Hi all,

I have a requirement that when the user clicks on the submit button for a form that the button be disabled so they won't/can't click it again before the next page appears. Sounds simple enough. I put some javascript like this:

function disable( input ) {
  input.disable=true;
}

To test it out in the html template I put this:

<input type="submit" jwcid="@Submit" tag="Yes" listener="..." onClick="javascript:disable(this);"/>

This works fine when the submit button is part of a form that uses the form's listener. But when I have multiple buttons and need to rely oon the buttons listener and tag attributes this fails. I made my own Submit component to add debugging and at first I thought that because it was disabled the rewind of the form was terminating. It turns out that the selected property is not being updated because the parameter for my component ( I assume this oarameter is the Tag value) is never being set. I think this is a function of the Direct service but I am still new to Tapestry.

Can someone shine some light on what it is I have to do to make this work? I don't see why the Tag attribute is not being placed in the parameters. Does my handling of the onclick have to change?

By the way I attempted to make my own Submit component using a Script but I could not get the initialization (onload) to do what I wanted. Anyway that is another question for another time. Any and all suggestions are quite welcome.

BTW I am using Firefox but IE will be supported as well

Thanks again

Doug Lochart
Cape Computing Corp


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to