javascript disable and form submit buttons

January 31, 2008

Had a form with multiple submit buttons which I was using to give the user different options as to what page the user would go to after the form was processed. Had a problem with users clicking the submit button more than once (and therefore data was being duplicated), so I put in a javascript to disable all the buttons after one of them was clicked once. Got a bug report soon after that the page the user was going to was the same no matter which of the submit buttons was being pressed.

The cause of the problem was that the “value” of whichever submit button was pressed wasn’t being submitted once the button was disabled. The solution was to create a hidden field to hold the value I was sending via the different submit buttons, and change the submits to plain buttons with an onclick attribute that set the value of the hidden field before submitting the form.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: