Click to See Complete Forum and Search --> : Alert Problems


JScriptNewbie
03-03-2003, 08:01 PM
When the "OK" button is pressed on an alert, I want more text to appear on my page, but only if the right choice is selected (this is from my select-and-go menu...it brings up alerts). If the wrong choice is selected, when the person hits the "OK" button, I want them to be located to another page. How do I do these things? Thanks!

-JScriptNewbie

pyro
03-03-2003, 08:15 PM
It sounds like you need to prompt users for answers. How are you going to check if they answer correctly? I think I'm confused as to how you would like to do this...

Dan Drillich
03-03-2003, 10:03 PM
The following can take you there -


<script>

function takeAction() {

// The right choice
var rightOne = 1;
var msg = "Do you want to see extra text to appear?";
var msg2 = "Can we redirect you to another page?";

var c = document.form1.menu1.selectedIndex;

if (c == rightOne) {
if (confirm(msg)) {
document.form1.extra.value = "Extra text...."
}
} else {
if (confirm(msg2))
location.replace("http://www.altavista.com");

}

}

</script>


<form name="form1">

<select name="menu1" onchange="takeAction();">
<option selected>-- select --</OPTION>
<option value="http://google.com">Google</option>
<option value="http://excite.com">Excite</option>
</select>

<br>

<input type="text" name="extra">

</form>

Eag|e
03-04-2003, 09:24 AM
Couldn't you just do it like its a boolean? Do it so that like

<script language = "JavaScript">
var message = window.alert("Some Text here")
If (message == True)
{
do something here
}
else
{
do something else here
}
</script>
Couldn't you do it like dat? Just a suggestion :/ Good luck!