?
Solved

Message box having Yes and No Buttons instead of Ok and Cancel buttons

Posted on 2004-10-26
4
Medium Priority
?
10,561 Views
Last Modified: 2012-08-13
Hi
I would like to know whether we can have a message box with Yes and No Buttons in Javascript. I am aware of the confirm message box having OK and Cancel Buttons, but my requirements is for a message box with Yes and No buttons. I am aware that we can define the number of boxes in a message box using VBScript, but i have to give the same functionality using Javascript. Please help asap.

Regards

Prashant
0
Comment
Question by:pvasha
  • 2
4 Comments
 
LVL 33

Accepted Solution

by:
sajuks earned 1200 total points
ID: 12408910
You can have the confirm box (as you already know) .The other alternative might be calling a modal
window ( that you create ) and use it.Other alternative being vbscript
0
 
LVL 33

Assisted Solution

by:sajuks
sajuks earned 1200 total points
ID: 12408923
//Check this, a code posted by another expert in this forum
<script language="JavaScript">
     function alertBox(alertMessage,height,width)
          {
          // This stuff centers the window
          windowWidth = (width == null) ? 200 : width; // width of the new window
         windowHeight = (height == null) ? 30 : height; // height of the new window
         windowLeft = (screen.width / 2) - (windowWidth / 2); // center the window right to left
         windowTop = (screen.height / 2) - (windowHeight / 2); // center the window top to bottom
         
          // the values get inserted into the features parameter of the window.open command...
          var windowLocation = "top=" + windowTop + ",left=" + windowLeft + ",height=" + windowHeight + ",width=" + windowWidth;
          alertWindow = window.open("","alertWindow",windowLocation);
          alertWindow.document.write("<html><head><title>Alert!</title></head><body bgcolor='#C0C0C0'>");
          alertWindow.document.write("<div align='center'>" + alertMessage + "<br>");
          alertWindow.document.write("<form><input type='button' value=' YES ' onclick='window.close()' align='center'></form>");
          alertWindow.document.write("</div></body></html>");
          }
</script>


// Here is the call:
<input type="button" value="test" onclick="alertBox('This is an alert!!!')">
0
 
LVL 3

Assisted Solution

by:andYetAnotherLoginName
andYetAnotherLoginName earned 150 total points
ID: 12408961
change
         alertWindow.document.write("<html><head><title>Alert!</title></head><body bgcolor='#C0C0C0'>");

to
         alertWindow.document.write("<html><head><title>Alert!</title></head><body bgcolor='buttonface' style='border:0px none'>");

for better appearence.
0
 
LVL 5

Assisted Solution

by:mrielf
mrielf earned 150 total points
ID: 12409613
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

594 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question