E43509
Posts: 283
|
| Posted: 07/30/2007, 12:40 PM |
|
I have a separate grid and separate record form that upon submit, does the update and goes back to grid form.
One of my deployments has a slow connection and folks poke the submit button multiple times which causes my data to get hosed.
Googling around everyone says it is easy to disable the submit with javascript.
onclick="this.disabled=true;"
and that does disable it but the form does not seem to be submitted and instead of redirecting to the grid page, it stays on the record page.
( http://willmaster.com/possibilities/archives/wmp20040928001.shtml )
So instead I hide the button on click and show a dummy button that is disabled. This works but I'm not keen on it.
My dummy button
<input class="Button" id="disabledSubmit" style="DISPLAY: none" disabled type="button" value="Submit" name="disabledSubmit">
The real submit with js onclick event
<!-- BEGIN Button Button_Submit --><input class="Button" onclick="this.style.display='none';document.getElementById('disabledSubmit').style.display='';" type="submit" value="Submit" name="{Button_Name}"><!-- END Button Button_Submit -->
Any thoughts?
|
 |
 |
dragoon
Posts: 173
|
| Posted: 07/31/2007, 2:56 AM |
|
disable the submit button onSubmit of the form instead onClick of the button
|
 |
 |
E43509
Posts: 283
|
| Posted: 07/31/2007, 4:21 AM |
|
I have also tried that with this javascript code and I get the same effect. Form data is not submitted and the form gets lost and just returns to itself. (all querystring params are gone).
<form ... onsubmit="document.getElementById('Button_Submit').disabled=true">
?? Next steps?
|
 |
 |
E43509
Posts: 283
|
| Posted: 07/31/2007, 4:22 AM |
|
Before I forget ... in all the examples above the button does get greyed out and I have no JS errors.
|
 |
 |
DonB
|
| Posted: 07/31/2007, 3:38 PM |
|
Try this:
<input type="submit" onclick="this.onclick= function() {return false;};
return true;" name="Button_Submit">
This will submit the form the first time you click the button, but will
(should) do nothing after that - because it redefines the 'onclick' function
to be 'return false;', which effectively disables the submit action. The
'return true' allows the submit to proceed on the initial click.
--
DonB
http://www.gotodon.com/ccbth
"E43509" <E43509@forum.codecharge> wrote in message
news:246af1b5f4b55b@news.codecharge.com...
> Before I forget ... in all the examples above the button does get greyed
out and
> I have no JS errors.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
|
|
|
 |
Tuong Do
|
| Posted: 07/31/2007, 4:53 PM |
|
Do not disable the button
Hide the button when onclick so they can only click it once
document.getElementById('YourbuttonID').style.display = 'none';
"E43509" <E43509@forum.codecharge> wrote in message
news:246ae3ecb5d2c6@news.codecharge.com...
>I have a separate grid and separate record form that upon submit, does the
> update and goes back to grid form.
> One of my deployments has a slow connection and folks poke the submit
> button
> multiple times which causes my data to get hosed.
> Googling around everyone says it is easy to disable the submit with
> javascript.
> onclick="this.disabled=true;"
> and that does disable it but the form does not seem to be submitted and
> instead
> of redirecting to the grid page, it stays on the record page.
> ( http://willmaster.com/possibilities/archives/wmp20040928001.shtml )
>
> So instead I hide the button on click and show a dummy button that is
> disabled.
> This works but I'm not keen on it.
> My dummy button
> <input class="Button" id="disabledSubmit" style="DISPLAY: none"
> disabled
> type="button" value="Submit" name="disabledSubmit">
>
> The real submit with js onclick event
> <!-- BEGIN Button Button_Submit --><input class="Button"
> onclick="this.style.display='none';document.getElementById('disabledSubmit').style.display='';"
> type="submit" value="Submit" name="{Button_Name}"><!-- END Button
> Button_Submit
> -->
>
> Any thoughts?
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
E43509
Posts: 283
|
| Posted: 08/01/2007, 6:56 AM |
|
Way cool DonB
I tried it and it seems to work well!
I never would have thought of that.
Thanks
|
 |
 |
DonB
|
| Posted: 08/02/2007, 8:21 AM |
|
I had another thought. You could put an alert('already submitted') in the
function, so that after the button is clicked once, there's a message to
indicate they already clicked it.
--
DonB
http://www.gotodon.com/ccbth
"E43509" <E43509@forum.codecharge> wrote in message
news:246b091187e66d@news.codecharge.com...
> Way cool DonB
> I tried it and it seems to work well!
> I never would have thought of that.
> Thanks
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
|
|
|
 |