/    Sign up×
Community /Pin to ProfileBookmark

how to force click event on disabled submit button

Hi all,

I’m new to these boards and my javascript experience is fairly limited and basic so please bear with me. Anyway, on to the question and some background. I’m developing using ColdFusion 4.5 and a good deal of the page processing depends on whether or not a control is defined. To prevent users from clicking on a submit button more than once or clicking on another submit button before the page has finished processing I have decided to use javascript to disable all of the submit buttons on the page. However, this is preventing submission of the form. When I try forcing the submit in the function, the processing that should occur from clicking the submit button is ignored and the submit button is not defined. Here is the code I am using the commented code is different things I have tried:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>

<html>
<head>
<title>Untitled</title>
<script language=”JavaScript”>
function fxnDisableBtn(foo)
{
//alert(foo.type + “, ” + foo.name + “, ” + foo.value);
//document.frm1.foo.click();
//document.frm1.submit();
document.frm1.btnSave.disabled = true;
document.frm1.btnGoBack.disabled = true;
document.frm1.btnReturn.disabled = true;
document.frm1.btnForward.disabled = true;
//document.frm1.submit();
//document.frm1.foo.click();
switch(foo.name){
case “btnSave”:
//alert(foo.type + “, ” + foo.name);
//document.frm1.btnSave.click();
foo.click();
break;
//document.frm1.btnSave.click();
case “btnGoBack”:
//alert(foo.type + “, ” + foo.name);
document.frm1.btnGoBack.click();
//foo.click();
break;
case “btnReturn”:
//alert(foo.type + “, ” + foo.name);
//document.frm1.btnReturn.click();
break;
case “btnForward”:
//alert(foo.type + “, ” + foo.name);
//document.frm1.btnForward.click();
break;
}
alert(foo.type + “, ” + foo.name + “, ” + foo.value + “, ” + foo.disabled + “, ” + foo.click()); //debugging and checking foo
}
</script>
</head>

<body>
<form name=”frm1″ action=”#Application.RootPath#/master.cfm?” method=”post”></form>

<input type=submit name=”btnSave” value=”Save (Does Not Forward)” onclick=”fxnDisableBtn(btnSave);”>
<br><br>
<input type=submit name=”btnGoBack” value=” <- Back ” onclick=”fxnDisableBtn(btnGoBack);”>&nbsp;&nbsp;&nbsp;

<input type=submit name=”btnReturn” value=”Return” onclick=”fxnDisableBtn(btnReturn);”>&nbsp;&nbsp;&nbsp;

<input type=submit name=”btnForward” value=”Forward” onclick=”fxnDisableBtn(btnForward);”>
<br><br>

</body>
</html>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@jonesauthorJan 09.2004 — bump

help...
×

Success!

Help @jones 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.17,
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,
)...