Click to See Complete Forum and Search --> : Multiple Functions with one button using onclick


smallz
07-30-2005, 03:29 AM
Hi there, Javascript gurus!

SIMPLE problem, but this is driving me nuts!!!

I’m using a javascript script that lets you type in values in a text box, and when you click a button it saves it as a cookie.

The code for this button is:

<INPUT onclick=javascript:setFields(); type=button value=" Set " tabindex="4">

The button works fine.

I also need a button that redirects you to another page, much like this button:

<INPUT type=button value=" Redirect " tabindex="4" onClick=window.location='http://www.whatever.com'>

This button works fine.

Here’s the problem:

I need ONE button to perform these TWO things.

When I combine the two…

<INPUT type=button value=" Set and Redirect " tabindex="4" onclick="javascript:setFields(); onClick=window.location='http://www.whatever.com'">

The cookies are set, but I don’t get a redirect.

How do I make the button redirect as well as set the cookies? What do I need to change with the last piece of code?

Or… is there some other way I should be going about this?


Many thanks,

John

PS My deepest apologies – I’m a javascript/coding absolute newbie :-/ Please keep your replies as dumbed-down as poss :-)

vwphillips
07-30-2005, 04:26 AM
onclick="javascript:setFields();window.location='http://www.whatever.com';"

felgall
07-30-2005, 05:46 PM
or even

onclick="setFields();window.location='http://www.whatever.com';"

smallz
07-30-2005, 09:02 PM
hey guys...

thanx so much for your responses.

they both work in netscape, but NOT in internet explorer...

the cookies are set, but still no redirection.

this is really irritating. :confused:

what could be wrong here? what could I do to fix this?

Thanx again :)

smallz
07-31-2005, 06:11 AM
problem resolved...

the issue was that the function 'setfields' told the browser to reload (which interfered with the redirect command).

thanx for your help though folks!