Click to See Complete Forum and Search --> : Form button disabled
IncaWarrior
07-24-2003, 08:24 PM
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?
Khalid Ali
07-24-2003, 08:40 PM
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
IncaWarrior
07-24-2003, 08:52 PM
the form is just disabled so that people won't submit twice
anyone know how to do it?
IncaWarrior
07-25-2003, 01:30 PM
you people aren't much help
rstaticn
07-25-2003, 02:01 PM
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.
Originally posted by IncaWarrior
you people aren't much help None of us are paid to help...
Khalid already answered you. You need serverside coding.
IncaWarrior
07-25-2003, 07:16 PM
but you come here to help...
i don't believe him about that
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.
IncaWarrior
07-31-2003, 06:07 PM
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>