PDA

View Full Version : Can't get a Confirm Window to work!


joker
12-29-2002, 11:13 AM
Hello all,
I can't get the function to work.
Here is the function:

function Validation()
{
if (confirm("Sending an email?\n\nIf you wish to proceed click on <OK>; If not, click on <CANCEL> to abort"))
{
alert("true");
return true;
}
else
{
alert("false");
return false;
}
}

and here is the form:

<form method="POST" action="https://www.myserver.com/cgi-bin/redirect.pl">
<p align="right"><font size="2" face="Arial">
<select size="1" name="leave" onSubmit="return Validation();">
<option value="https://www.myserver.com/sendmail.php3?option=<?php echo "option1" ?></option>
<option value="https://www.myserver.com/sendmail.php3?option=<?php echo "option2" ?></option>
<option value="https://www.myserver.com/sendmail.php3?option=<?php echo "option3" ?></option>
</select></font></td>
<td><p align="left"><input type="submit" value="MailIt" name="mail"></p></td>
</form>

Any ideas?

Algorithm
12-29-2002, 11:20 AM
The onSubmit attribute should be in the FORM tag, not the SELECT tag.

joker
12-29-2002, 03:52 PM
tried it but still doesn't work.

brothercake
12-29-2002, 04:27 PM
works for me


<html><head></head><body>


<script>

function Validation()
{
if (confirm("Sending an email?\n\nIf you wish to proceed click on <OK>; If not, click on <CANCEL> to abort"))
{
alert("true");
return true;
}
else
{
alert("false");
return false;
}
}

</script>

<form method="POST" action="https://www.myserver.com/cgi-bin/redirect.pl" onSubmit="return Validation();">
<p align="right"><font size="2" face="Arial">
<select size="1" name="leave">
<option value="https://www.myserver.com/sendmail.php3?option=<?php echo "option1" ?></option>
<option value="https://www.myserver.com/sendmail.php3?option=<?php echo "option2" ?></option>
<option value="https://www.myserver.com/sendmail.php3?option=<?php echo "option3" ?></option>
</select></font></td>
<td><p align="left"><input type="submit" value="MailIt" name="mail"></p></td>
</form>

</body></html>

duniyadnd
12-29-2002, 04:52 PM
worked for me too, just have to change where your onselect is located as algorithm specified.

duniyadnd

joker
12-30-2002, 04:06 AM
yeap! it works for me too. I had misplaced the onSubmit function.

thanks a bunch.