preventing form double-submits - the plot thickens

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
titaniumdoughnut
Forum Commoner
Posts: 33
Joined: Wed Jul 13, 2005 2:02 pm
Location: Manhattan

preventing form double-submits - the plot thickens

Post by titaniumdoughnut »

I know this isn't strictly PHP, but I figure someone will know the answer anyway.

I have a load of HTML forms, and I don't want double-submits, so I did the old button-turns-grey-after-you-click-it technique.

Code: Select all

<input type="submit" value="Sign up!" onclick="this.disabled = true;form.submit()">
I had to add the form.submit() bit because Safari wasn't actually submitting for some reason.

Now, here's the problem. A lot of users click back and change something when a form doesn't work because they didn't fill it out properly. The buttons are still grey when I go back. Is there a way to ungrey them when the user goes back to the page? This is rather perplexing, because it doesn't seem like a load event would even be called.

Maybe I'm just doing this wrong? I'd rather not do checking on the server-side, for various reasons.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Why not simply provide a one-time use token for the form to submit?
User avatar
titaniumdoughnut
Forum Commoner
Posts: 33
Joined: Wed Jul 13, 2005 2:02 pm
Location: Manhattan

Post by titaniumdoughnut »

It just gets far too icky to keep track of tokens. The site is chock-full of submits, for everything from contributing content to logging in, tagging people, editing profiles, etc. Double-submits aren't the end of the world, so I don't NEED that kind of protection, and it gets really annoying dealing with tokens everywhere.

Unless there's some simple way I'm not thinking of.

Anyways, I know I've seen the grey-button trick work. I just need to figure out what I'm doing wrong.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

You could switch the input button with a different element if the submit has been successful the first time. I like how Newegg makes the button say "processing.." so you don't accidentally double click the submit button. It's usually a problem with less savvy computer users who think they have to double click everything. I've seen people do it on power buttons! :lol:
User avatar
titaniumdoughnut
Forum Commoner
Posts: 33
Joined: Wed Jul 13, 2005 2:02 pm
Location: Manhattan

Post by titaniumdoughnut »

Ah, yes. I like switching the text of the button to say "processing..."

Now, see... my problem is that any switch I do will stay in effect if the user reaches the next page, changes their mind, and clicks back. Pages aren't reset when you go back to them. They stay in the state they were left in. I need the button to return to its default clickable friendly state when you go back to its page.
Post Reply