submit button, js

OuiKikUrAzz

Senior member
Sep 14, 2001
313
0
76
how can i use js to make the submit button un pressable after it has been pushed so it can only be submitted once?
 

Argo

Lifer
Apr 8, 2000
10,045
0
0
<form name="myform>
<input name="mybutton" type="button" onClick=javascript:Document.myform.mybutton.disabled=true>
</form>
 

OuiKikUrAzz

Senior member
Sep 14, 2001
313
0
76
inputed it and when I click it it says document is undefined, i changed 'myform and myname' to appropriate values already.
 

Argo

Lifer
Apr 8, 2000
10,045
0
0
In that case remove document alltogether. Just have javascript:formname.buttonname.disabled=true;


Btw, this would work only in IE
 

OuiKikUrAzz

Senior member
Sep 14, 2001
313
0
76
ok that worked but when i push submit it just makes it unclickable and doesn't process the form
 

Argo

Lifer
Apr 8, 2000
10,045
0
0
Change the line to read this


onClick=formname.buttonname.disabled=true;formname.submit();
 

Shazam

Golden Member
Dec 15, 1999
1,136
1
0
This actually works better:

<input type="submit" onclick="javascript: this.disabled=true;">

If you use the submit() method, it will bypass any calls that are in the onsubmit event, which you may not want to do.
 

OuiKikUrAzz

Senior member
Sep 14, 2001
313
0
76
that method actually doesn't submit the form, it makes the button on pressable once and doesn't submit the form for processing