Entry
How to write YESNO message box in javascript?
Jan 8th, 2003 18:39
Jean-Bernard Valentaten, Kulandaivadivel Duraisamy,
Unlike Java, C++, VisualBasic etc. JavaScript will not allow you to
manipulate the widgets, so it is not possible to write a real YESNO
message box using JavaScript only.
But there are workarounds and features that will let you get a decision
by the user.
The first way is to use the confirm() method located in the window
container:
function YESNOBox(msg)
{
return confirm(msg);
}
The confirm method opens a panel displaying a string (called msg in the
function above) and two buttons ("OK" and "Cancel"). If "OK" is clicked
confirm() returns true else false.
If this doesn't suit you, you will have to write some html-code that
shows the panel the way you want it to look and have some JavaScript
return true or false depending on which button was clicked.
HTH,
Jean