PDA

View Full Version : Pop-up/form script


adam*
07-01-2002, 11:52 AM
I need a script to do the following:

When one specific option is selected and submitted from a drop down (form option) menu and submitted I want a pop-up box with a text message and an "OK" button to click, before being taken through in the main window to another page.

I've acheived a similar thing with an image map using the following code:

<AREA SHAPE="poly" COORDS="165,99, 168,118, 182,118, 186,114, 177,103, 177,98" onClick="alert('My text message here.');window.top.location.href('myurl.htm')">


Any suggestions???

premshree
07-01-2002, 12:10 PM
Well, why don't you use a simple drop-down-menu and give the same events that you gave in the <AREA> tag.

joh6nn
07-01-2002, 12:15 PM
<form name="formName">
<select name="selectBox" onchange="foo();">
<option>the text of your option</option>
</select>
</form>
function foo() {
if (document.formName.selectBox.options[document.formName.selectBox.selectedIndex].text == "the text of your option") {
alert("bar");
window.location = "whereever.htm";
}
}

adam*
07-01-2002, 12:45 PM
thanks.

Have just tested both in Netscape, and my onClick="alert('My text message here.');window.top.location.href('myurl.htm')" doesn't work at all.

Any alternative suggestions?

joh6nn
07-01-2002, 01:55 PM
the code i posted should do what you want.

adam*
07-01-2002, 04:35 PM
...the code you posted worked fine for the form. However, the code I already had for the image map doesn't work in Netscape.

I tried adapting your code as well - swaped my window.top.location.href for your window.location - but again, it only worked in IE.

joh6nn
07-01-2002, 04:56 PM
which version of netscape?

adam*
07-01-2002, 05:00 PM
4.79

joh6nn
07-01-2002, 05:03 PM
netscape 4 doesn't support the onclick event in image maps. there's nothing you can do about it. it will work in every other browser, though.

adam*
07-01-2002, 05:05 PM
Oh, ok. Thanks for the info.