...

View Full Version : Javascript alert with Yes No buttons



garrisonian14
12-11-2007, 07:44 AM
Hi,

I want to show an alert box With Yes No Button..
Like:
You want to proceed

Yes No


Alert gives just OK, and confirm gives Ok and Cancel buttons

Kindly tell me how can i get Yes And No buttons there.

It is urgent please....

Thanx,

Ali

felgall
12-11-2007, 07:48 AM
You will have to build your own in page dialog using HTML. See http://javascript.about.com/library/blmodald1.htm for how to create a basic one with one button. Changing the HTML to add a second button and the JavaScript to test which button was pressed is a trivial change.

Philip M
12-11-2007, 08:25 AM
<p> Do you want to proceed?" </p>
<input type = "button" id = "ybutton" value = "Yes" onclick = "buttonwhich('You pressed YES')">
<input type = "button" id = "nbutton" value = "No" onclick = "buttonwhich('You pressed NO')">
<input type ="text" id = "answerbox">

<script type = "text/javascript">
function buttonwhich(message) {
document.getElementById("answerbox").value = message;
}
</script>

rnd me
12-11-2007, 12:14 PM
for an easier to code synchronous solution,

showModalDialog works in ie (http://msdn2.microsoft.com/en-us/library/ms536759.aspx) and in firefox3 (http://developer.mozilla.org/en/docs/DOM:window.showModalDialog)

felgall
12-11-2007, 06:55 PM
for an easier to code synchronous solution,

showModalDialog works in ie (http://msdn2.microsoft.com/en-us/library/ms536759.aspx) and in firefox3 (http://developer.mozilla.org/en/docs/DOM:window.showModalDialog)

Why use a solution that is proprietary to only one or two browsers rahter than one that should work in thousands of different browsers.

rnd me
12-12-2007, 03:06 AM
Why use a solution that is proprietary to only one or two browsers rahter than one that should work in thousands of different browsers.

firefox 3 will quickly replace firefox2 when it comes out.

combined with ie, "proprietary to only one or two browsers" will comprise 90&#37; of users. I try to worry more about the majorty than catering to and smaller interests. I have a hard time philosophically justififng limiting myself to pick up a few more people, who have other options available. Firefox is free and works on about any OS. If someone was dying to use my script, they could download firefox.


my major interest in using showmodal is the simplicity of coding.

compare the programming overhead of x=prompt("enter a value"), to
somethings using an HTML replacement. You need to define callbacks, validate the input, clean up the modified DOM after, and so forth. What showmodal does with about 20 chars worth of instruction, would take hundreds of chars with HTML.

As a compromise, show modal displays HTML. you could add your form right now for the "big two.5" browsers, and add the events and interaction code necessary to support that last 5-7%.


as a bit of retort, who is using the "thousands of different browsers" you mention?

I'll insert my 'snappy answer' to standards nazis here:
"what kind of standard is used by only 7% of the market?"




---------

as Spock says: "It's logical, the needs of the many outweigh the needs of the few.".

Philip M
12-12-2007, 06:54 AM
I'll insert my 'snappy answer' to standards nazis here:
"what kind of standard is used by only 7% of the market?"



"The nice thing about standards is that there are so many to choose from."



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum