[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


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

Posted on 2004-10-26
Medium Priority
Last Modified: 2012-08-13
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.


Question by:pvasha
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 33

Accepted Solution

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
LVL 33

Assisted Solution

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>");

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

Assisted Solution

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

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

for better appearence.

Assisted Solution

mrielf earned 150 total points
ID: 12409613

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

656 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