Click to See Complete Forum and Search --> : form submitting with a image field


natty
05-15-2003, 09:54 AM
hi all

im having real problems with users double clicking submit buttons.
these buttons are <input type=image ...
i have tried various approaches with no success.
i first tried

<form onsubmit="return foo();" ...>
<input type=hidden name=doneit value=''...
<input type=image name=submit ...

<head ..<scr..
function foo(){
if (d.forms[0].doneit == ''){
document.forms[0].submit.disabled = true;
return true;
}else{
return false;
}
}

the trouble with that is that it didnt work because it didnt seem to disable the button.

then tried

if(blah){
document.forms[0].done.value = true;
document.forms[0].action = '';
document.forms[0].submit();
return true;
}else{
return false;
}

but that didnt work because the return false on the second click stopped the submitting of the page.

then i tried to make the submit button in to a hyperlink anad do all the form action in the JS

function foo(){
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();
}
}

but that didnt work becasue on the second click the page jumped to the top, having taken the href='' to mean href=# ...
surely there must be a way to do this ?

thanks in advance.. (i hope)
nat

khalidali63
05-15-2003, 10:11 AM
Hey is it possible for you "in plain text"...:D
Explain what is the problem and post a link to the actual page or postfull code(html+js)

Nevermore
05-15-2003, 11:33 AM
Why is double clicking such a problem?

Jona
05-15-2003, 11:37 AM
Quite confusing, I say.

<form action="" onsubmit="return foo(this);">

function foo(f){
// in this instance, f = document.forms[0]
if(f.doneit.value = ""){
f.submit.disabled = true;
return true;
} else {return false;}
}

Of course, this would only work if your submit button was named, "submit."

Jona
05-15-2003, 07:14 PM
That's what I figured, Dave. I should've said something about that.