...

View Full Version : Action on the response from an alert with yes/no



Phalanxer
07-04-2012, 10:01 AM
I was wondering if someone can give me a quick example of how to make an alert on click - where if the user toggles yes then submit, and if the user toggles no, then do nothing.

I have come up with this so far:



<SCRIPT type="text/javascript">
function validateForm() {
alert ("Confirmation: End session?");
return false;
}
</SCRIPT>

Philip M
07-04-2012, 10:11 AM
Use a confirm box.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

Phalanxer
07-04-2012, 10:17 AM
Where abouts in the manual can I find this?

Phalanxer
07-04-2012, 10:25 AM
<SCRIPT type="text/javascript">
function confirmForm() {
confirmation = confirm("Confirmation: End session?");
if (confirmation == false) {
return false;
}
}
</SCRIPT>


Solved.

Dormilich
07-05-2012, 10:28 AM
there is no need to test for false to return false ... simply return confirm()’s return value.

function confirmForm() {
return confirm("Confirmation: End session?");
}
your original function has the problem that (if the confirmation is true) the function returns a falsy value (namely undefined) and not a truthy value, which can fire back when you do onsubmit="return confirmForm()" or

if (!confirmForm()) {
// do not submit
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum