Click to See Complete Forum and Search --> : Prompt a user
mrskumm
02-28-2003, 01:57 PM
Hi...
I want to promt the user if some information is correct or not, popping up a Yes/No box, and depending on their answers do certain things, but all I find is promt() confirm() etc... :(
Originally posted by mrskumm
but all I find is promt() confirm() etc... :( And why won't these work?
dabush
02-28-2003, 02:16 PM
yea. prompt() will get the user to enter in words, and confirm() will be a ok/cancel popup.
mrskumm
02-28-2003, 03:07 PM
Sorry!! My mistake, confirm() was what I was looking for!
You're wondering how to use it? If so, view the following example:
<script language="javascript" type="text/javascript">
var yesno = confirm ("Choose OK or Cancel","");
if (yesno == true)
{
alert ("OK was chosen");
}
else
{
alert ("Cancel was chosen");
}
</script>
Charles
02-28-2003, 03:32 PM
And you can shorten that up quite a bit.
<script type="text/javascript">
if (confirm ('Choose OK or Cancel','')){alert ('OK was chosen')} else {alert ('Cancel was chosen')}
</script>
The reason I coded it the way that I did was because I figured that mrskumm would want to do more than a simple alert, so it is easier to view the code if you don't try to throw it all on one line... ;)