Submit only once.

V

Vincent M.

Hello,

I have a form which allow to submit a file, I'd like to block the submit
buton once it has been clicked, so I tried:

function SubmitNow(item){
if(item.value=="Please wait") {
return false ;
} else {
item.value="Please wait" ;
item.form.submit ;
}
}

With inside the submit buton:

<input class=submit type=submit value=Valid name=submitbtn
onClick="SubmitNow(this);">

But it does not work :( We can send several times the same file...

Any idea ?

Thanks,
Vincent.
 
S

Stuart Palmer

This might be a nasty idea but what about putting the button in a div and
when it's clicked hide the dive so the button can't be repressed (as it's
then hidden)
Just my initial thought.

Stu
 
L

Lasse Reichstein Nielsen

Vincent M. said:
I have a form which allow to submit a file, I'd like to block the
submit buton once it has been clicked, so I tried:

Highly annoying! I sometimes use a web site where they do that. I
submit something for a search, and then later use the back button to
get back and do another search, but it doesn't work. Do I have to
reload the page and lose the entered data.

How about just using a confirm dialog asking "Are you sure you want
to submit this form more than once?"?
function SubmitNow(item){
if(item.value=="Please wait") {
return false ;

i.e.: return confirm("Are you sure ... more than once?");
} else {
item.value="Please wait" ;
item.form.submit ;

This line does nothing. It doesn't call the functions. It doesn't
have to either, since the function returns undefined, so the normal
effect of the click should take effect. I recommend keeping it
this way. I.e., just drop that line.
}
}


With inside the submit buton:

<input class=submit type=submit value=Valid name=submitbtn
onClick="SubmitNow(this);">

You don't return the result of SubmitNow, so the return false is
irrelevant. Change it to
onclick="return SubmitNow(this)"
But it does not work :( We can send several times the same file...

You could even remember the names of the files that have already
been sent and only warn if the same file is sent twice.

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top