/    Sign up×
Community /Pin to ProfileBookmark

Disabling buttons prevents passing of POST variables

I wrote this function to disabled submit/reset buttons on a form upon submission (so that they can’t resend the data in the middle of processing it).

[code=php]function formButtonsDisableOnSubmit() {
var forms=document.getElementsByTagName(“FORM”);
for(var i=0; i<forms.length; i++) {
forms[i].onsubmit=function() {
var inputs=this.getElementsByTagName(“INPUT”);
for(var ii=0; ii<inputs.length; ii++) {
if(inputs[ii].type == “submit” || inputs[ii].type == “reset”) {
inputs[ii].disabled=true;
}
}
}
}
}[/code]

However, when I disabled the submit buttons it does not pass their values to the next page (a PHP page). Because of this, it doesn’t work when I have multiple SUBMIT buttons in a form. I need to be able to check which submit button was pushed via PHP, but since no values are passed for the button, I can’t. Any ideas?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterAug 21.2005 — &lt;form onsubmit="return submitOnce(this)"&gt;

<i>
</i>&lt;script type="text/javascript"&gt;
var fSubmits=[];
function submitOnce(t){
for(var i=0;i&lt;fSubmits.length;i++){
if(f==fSubmits[i]){return false}
}
fSubmits[fSubmits.length]=t
return true
}
&lt;/script&gt;
×

Success!

Help @Daniel_T 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...