Discussion Locked

EASY Javascript question

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello,
I am trying to create an alert w/ javascript that when you click OK it takes you to one page and when you click CANCEL it takes you to another (NOT just back one in history but to a whole new page) I can't figure it out.
Is there any wayto change the buttons from OK and Cancel to YES and NO? (that's not too important though) Thanks in advance for the help.

5 replies

by cedric king

In your , write:

If "OK" is a "Submit" button, use:
<....... onSubmit="javascript:OKIsClick()">
If "OK" is a "Image" button, use:
<....... onClick="OKIsClick()">

This should work.

by kevin.riggs

You want to use the confirm() function in Javascript.

test()
{
confirm("Question", "window.location='1stpage.htm'", "window.location='2ndpage.htm'");
}

This will allow you to post any question where I have used the word "Question" and the confirm() function will automatically redirect the user to the appropriate location. You could really juice up the function as below so that you can pass any number of questions into your function.

2nd example:

test(q, one, two)
{confirm(q, "window.location=" + one, "window.location=" + two);
}

Kevin

This discussion is closed to new replies.