/    Sign up×
Community /Pin to ProfileBookmark

Form button disabled

i am trying to make a form that will disable after it has been clicked. i found this code:
<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
function disableForm(theform) {
if (document.all || document.getElementById) {
for (i = 0; i < theform.length; i++) {
var tempobj = theform.elements[i];
if (tempobj.type.toLowerCase() == “submit”)
tempobj.disabled = true;
}
}
}
// End –>

(I think that’s all i need from it)
in the head and:

<form method=post action=”[form_action]” onSubmit=”return disableForm(this);”>

and the form (<input type=submit name=submit value=”Submit”>).

the button becomes disabled after clicking on it, but it is not submitted, anyone know how to do this?

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliJul 25.2003 — This is completely wronglogic.since when you submit a form it is suppose to go to a destination andonce the action is triggered the actual form is out of scope...you will need to use the server side langauges
Copy linkTweet thisAlerts:
@IncaWarriorauthorJul 25.2003 — the form is just disabled so that people won't submit twice

anyone know how to do it?
Copy linkTweet thisAlerts:
@IncaWarriorauthorJul 25.2003 — you people aren't much help
Copy linkTweet thisAlerts:
@rstaticnJul 25.2003 — two things

a) you might need to have a return true statement at the end of the function, thats why you might not be acutally submitting the form, or take out the return word when calling the function.

b) or you might want to submit it using form.submit() function at the end of the function.
Copy linkTweet thisAlerts:
@pyroJul 25.2003 — [i]Originally posted by IncaWarrior [/i]

[B]you people aren't much help [/B][/QUOTE]
None of us are paid to help...

Khalid already answered you. You need serverside coding.
Copy linkTweet thisAlerts:
@IncaWarriorauthorJul 26.2003 — but you come here to help...

i don't believe him about that
Copy linkTweet thisAlerts:
@YoggJul 26.2003 — Just put the whole form into a <div id="something'>

and add a onsubmit="document.getElementById('something').style.display = 'none';" in your submit button tag.
Copy linkTweet thisAlerts:
@IncaWarriorauthorJul 31.2003 — ok i scrapped that and i have one that does the same thing:

function postit() {

window.document.form1.fake.value=window.document.form2.text.value;

window.document.form2.submit();

window.document.form1.normal.disabled="true";

window.document.form2.action="[form_action]";

}




<form name="form1" method=post action="[form_action]" onSubmit='postit()'>

<table border=0 cellpadding=3 cellspacing=0>

<tr><td align=left valign=top>Text:</td>

<td align=left>

<textarea rows=6 cols=35 name="fake" wrap=virtual></textarea>

</td></tr>

<tr><td></td><td align=left valign=top>

<input type=submit name="normal" value="Submit">

</td></tr></table>

</form>

<form name="form2" method=post action="[form_action]">

<input type="hidden" name="text" Value=""></form>
×

Success!

Help @IncaWarrior 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.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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

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