homepage Welcome to WebmasterWorld Guest from 54.227.12.4
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
javascript form submitting
natty




msg:1487161
 12:04 pm on May 14, 2003 (gmt 0)

hi all,

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

 

ShawnR




msg:1487162
 12:49 pm on May 14, 2003 (gmt 0)

Hi Nat

Lets say:
<form name="form1" onsubmit='javascript:return cont();' method=post action="2.html">
<input type="submit" id="my_button" name="action" value="Submit">
</form>

How about:

document.form1.elements['my_button'].disabled = true;

Shawn

natty




msg:1487163
 12:57 pm on May 14, 2003 (gmt 0)

i was under the impression that you could not turn off image buttons..?!?!?

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

ShawnR




msg:1487164
 1:20 pm on May 14, 2003 (gmt 0)

Sorry, I missed taht in your first post. In that case:
<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

natty




msg:1487165
 1:25 pm on May 14, 2003 (gmt 0)

ill give that a try, cheers matey.
i wasnt aware that you could turn of image submits like i says..
but for the older browwsers i tried..

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.

ShawnR




msg:1487166
 2:59 pm on May 14, 2003 (gmt 0)

I hope I am reading your post (#5) correctly... My thoughts are you can do pretty much the same thing by:

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved