Gossamer Forum
Home : General : Perl Programming :

Multiple OnClick events

Quote Reply
Multiple OnClick events
Hi

I would like to do 2 things using the the same OnClick function:

Code:
< INPUT type=submit value=Submit name=button Onclick="return ValidateAll2()" Onclick="this.value='Please Wait...'" >
Would anyone know how to combine these OnClick things to work together?

What I would like to do is have the validation routine run first, and then the Please Wait thing if the validation goes okay.

Many thanks Smile

DT
Quote Reply
Re: [DogTags] Multiple OnClick events In reply to
Can you not put the second event inside ValidateAll2() ?

My JS is pretty shaky.
Quote Reply
Re: [DogTags] Multiple OnClick events In reply to
Close... it's

onClick="function1(); function2();"

Haven't tried it with this.value though...
Quote Reply
Re: [Watts] Multiple OnClick events In reply to
Thanks for your helpSmile

I gave the following a try, but no luck:
Code:
<INPUT type=submit value=Submit name=button Onclick="return ValidateAll2();this.value='Please Wait...'">
The validate routine worked fine, but the "this value" thing never turned on.

There's no question that the validate thing is more important, but I thought it would be nice to have the button change to help prevent unnecessary clicks of the submit button.

If anyone might know of any trick to getting these two guys to work together, I'd be most grateful.

Many thanks to allSmile

DT
Quote Reply
Re: [DogTags] Multiple OnClick events In reply to
In the validate sub, at the top, how about adding....

Form_Name.button.value = 'Please wait';
Quote Reply
Re: [RedRum] Multiple OnClick events In reply to
or maybe switching the two statements around? I don't know javascript so it's just a wild guess Wink

Adrian
Quote Reply
Re: [brewt] Multiple OnClick events In reply to
Quote:
or maybe switching the two statements around? I don't know javascript so it's just a wild guess Wink
Yep, that'll do it. Cool

- Mark

Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: [AstroBoy] Multiple OnClick events In reply to
I tried switching 'em, but now the validate routine doesn't kick in.Frown

Code:
<INPUT type=submit value=Submit name=button Onclick="return this.value='Please Wait...';ValidateAll2()">

Well, I think we gave it a good shot, anyway...

Thanks, one and allSmile

DT
Quote Reply
Re: [AstroBoy] Multiple OnClick events In reply to
Hi-

Have you tried intitiating the validate function using an onsubmit event handler in the form tag?

<form action="yourscript.cgi" method="POST" name="YourForm" onSubmit="return YourFunction()">

--
Matt G
Quote Reply
Re: [DogTags] Multiple OnClick events In reply to
Think of this as a perl function:

Onclick="return this.value='Please Wait...';ValidateAll2()">

which translates to:

Code:
sub OnClick {
return this.value="Please Wait...";
ValidateAll2();
}
See why ValidateAll2 will never be run? ;)

Try:

onclick="this.value='Please Wait...'; return ValidateAll2();"

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Multiple OnClick events In reply to
If you run into problems check out this script:

http://javascript.internet.com/.../submit-changer.html

Mike.
"I'm off to stuff loads and loads of paper down the toilet" - Vivian
Quote Reply
Re: [Alex] Multiple OnClick events In reply to
Many thanks to all Smile

I gave your code a try, Alex, and it worked fine.

I'm going to try Watts' script, too, for some other stuff.

Thanks, again, one and all for your help. Smile

DT