Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript alert, same as msgbox?

Status
Not open for further replies.

EntLover

Programmer
Jan 7, 2003
6
CA
Hi, would anyone know if its possible to create a YES/NO alert box in javascript that imitates the vbscript message box. I saw some code for the "confirm" JS alert but it looks like it only displays OK and CANCEL for buttons, I need YES and NO. Any ideas???

 
the confirm and alert dialogs are as good as it gets in javsacript

dialogs are not as manipalitive in ajvascript as the msgbox function in vbscript ---------------------------------------
{ str = "sleep is good for you. sleep gives you the energy you need to function";
ptr = /sleep/gi;Nstr = str.replace(ptr,"coffee");alert(Nstr); }
---------------------------------------
for the best results to your questions: FAQ333-2924

 
You need the confirm box....

<script>

msg = &quot;are you sure?&quot;

if (confirm(msg)){
//do this
}
else{
//do that
}
</script> Get the Best Answers! faq333-2924
&quot;A witty saying proves nothing.&quot; - Voltaire
mikewolf@tst-us.com
 
onpnt - don't forget the incredibly versatile (not) prompt box (which completes all of your possible popwindows in javascript....) Get the Best Answers! faq333-2924
&quot;A witty saying proves nothing.&quot; - Voltaire
mikewolf@tst-us.com
 
[lol]
I think it's so versitile I've never used it. ---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }
---------------------------------------
for the best results to your questions: FAQ333-2924

 
Using confirm will still give me the OK and CANCEL buttons instead of YES and NO. I guess I'll have to stick with those.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top