Forum Moderators: open
im having some problems with a image submit button and trying to stop it being double clicked..
atm i have this, which can stop the second click , but then doesnt continue from the first one..
any ideas..
i have had a look about but cant seem to find anything
function cont(){
if (document.forms[0].done.value == ''){
document.forms[0].done.value = true;
document.forms[0].action = '2.html';
document.forms[0].submit();
return true;
}else{
return false;
}
}
<form name=form1 onsubmit='javascript:return cont();' method=post>
am i way off track
cheer all
nat
had sort of decided to change the submit image button to a hyperlink, and handle all the form actions etc in the javascript. and then turning of the hyperlink after the first time round..
unless someone can think of anything better?
cheers
nat
<form name="form1" onsubmit='javascript:return cont();' method=post action="2.html">
<input type="image" src="url..." id="my_button" name="action" value="Submit">
</form>
How about:
document.getElementById('my_button').disabled = true;
(Won't work in older browsers, but will in latest of at least IE, NN, Opera). You may be able to tweak it to get it to work across browser...
Shawn
function cont(){
if (document.forms[0].done.value == ''){
var anchors = document.anchors;
for (var i=0;i<anchors.length;i++){
anchor = anchors[i];
if(anchor.name == 'submit'){
anchor.href="";
break;
}
}
document.forms[0].done.value = true;
document.forms[0].action = '2.html';
document.forms[0].submit();
}
}
btw done is a hidden field.
sadly when the link is clicked the second time, it now jumps to the top of the page, with a # after the url.. darn. like a named anchor.
function cont(){
if (document.forms[0].done = ''){
return false;
} else {
document.forms[0].done.value = 'true';
return true;
}
}
with
<form name="form1" onsubmit='javascript:return cont();' method=post action="2.html">
Yes? Or am I missing something?
Shawn