/    Sign up×
Community /Pin to ProfileBookmark

Disable Submit Image Button

I have a form with a Submit Button that is an image. I’d like to disable the button when the user clicks it once. How can I do this with an Image Button?

[code=html]
<input name=”imageField” type=”image” id=”imageField2″ src=”images/Btn_Submit.gif” alt=”Submit” />
[/code]

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@thraddashDec 01.2009 — Something like this:

[code=html]<input name="imageField" type="image" id="imageField2" src="images/Btn_Submit.gif" alt="Submit" onclick="this.disabled = true;" />[/code]
Copy linkTweet thisAlerts:
@harrierdhDec 01.2009 — <input name="imageField" type="image" id="imageField2" src="images/Btn_Submit.gif" alt="Submit" />

You could hide the button

document.getElementById(imageField2).style.visibility = "hidden";

Or you could have a global var in your javascript and use the onChange() event in the submit button or onSubmit() event.

var submitPressed = false;

When the user clicks the button the first time set submitPressed = true;

And on each subsequent event return false to the event.
Copy linkTweet thisAlerts:
@KorDec 02.2009 — I have a form with a Submit Button that is an image. I'd like to disable the button when the user clicks it once. How can I do this with an Image Button?

[code=html]
<input name="imageField" type="image" id="imageField2" src="images/Btn_Submit.gif" alt="Submit" />
[/code]
[/QUOTE]

Is it an [I]autosubmit[/I] action within your form? In this case you can't. Changing the session will make all the javascript changes lost.
Copy linkTweet thisAlerts:
@BracholeauthorDec 02.2009 — This is a "Review Your Order" page, and then a Submit button to process the order. So I need to disable the button once they click on it, to avoid procesing the order twice!
Copy linkTweet thisAlerts:
@KorDec 02.2009 — Use a server-side filter.
×

Success!

Help @Brachole spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...