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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Warning message by Javascript

Status
Not open for further replies.

klwong

Programmer
Dec 7, 2001
14
0
0
HK
I would like to ask how to write a warning message by javascript:
for example, if the user wish to take some action, then a warning box (similar to alert) appears and said
(Continue? Yes / No). If the user choose yes, the action continues; otherwise, the action is cancelled.

Any suggestion? Thanks a lot.
 

This:

Code:
alert(window.confirm('Do you really want to do this?'));

will return true if "OK" is clicked, false otherwise.

Hope this helps,
Dan


The answers you get are only as good as the information you give!

 

BTW - you cannot change the OK / Cancel buttons to say Yes / No instead. You should either:

- reword your question so it is more appropriate for the buttons given,

- write your own DHTML 'alert' box, or

- look into the possibilities of using VBScript (I believe you can customize the buttons, although wouldn't swear to that). Of course, this would alienate any non-IE users (not a good thing unless you're on an intranet with a known browser-base).

Dan


The answers you get are only as good as the information you give!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top