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

message box with Yes/No 2

Status
Not open for further replies.

jags22

Programmer
Oct 17, 2001
44
US
Is there a way to open a message box and have Yes return turn and No return false? I know about the confirm but the user really wants Yes/No. It really needs to be javascript also.

Any help is appreciated.

 
jags22, it's not possible to alter the button verbage on a confirm box. The closest you can come is by creating your own div popup box with custom HTML buttons. But that has the problem of not being modal (i.e. - you can still click the other buttons on the page) If an IE only option works for you, then you may want to consider using IE's javascript function showModalDialog which has 2 downfalls - 1. as I pointed out, it's IE only and 2. the popup box comes with an X button in the upper right corner so the user can close it w/o even clicking either of your buttons.

The best solution would be to convince your employer that OK/Cancel is the only option. You could add a message to the bottom of your confirm like "Click OK for Yes and Cancel for No".

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Thanks... that's what I was afraid of.
 
Here's another possible solution. Like Kaht said, how about making your own "pop-up" using a div tag with a border and 2 buttons that say yes or no (give them class="pop_up" or whatever class name you choose).

Kaht also mentioned that it's not modal so, yes, the user could still hit other buttons unless you create a function to temporarily remove them (not disable them, because onclick will still work on a disabled button).

function modalBox(exceptionClass,isModal)
{
var input=document.getElementsByTagName("input");
var i;
for (i=0; i<input.length; i++)
{
if (input.className!=exceptionClass)
{
if (isModal)
{
input.style.visibility="hidden";
}
else
{
input.style.visibility="visible";
}
}
}// end for i
}// end modalBox

The idea would be to call modalBox("pop_up",true) when you're displaying and then call modalBox("pop_up",false) when the user has clicked the yes/no option.

Sorry if it's a bit rough around the edges. Came up with it on the fly and am not looking for potential pitfalls with the design.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top