Yes/No Messagebox

B

Bart Van der Donck

Mark said:
Is it possible to have a Yes/No Messagebox with Javascript

if (confirm('Like cookies?')) { document.write('you like cookies!') }
 
D

Dr J R Stockton

In comp.lang.javascript message <Xns98AD8D0256793RrrrFfffTttt4396hotm@21
6.168.3.44>, Wed, 3 Jan 2007 19:51:42, Jim Land
This is a FAQ.

4.28 How do I change the confirm box to say yes/no or default to
cancel?

The buttons on a confirm box cannot be changed, nor can you specify a
default button. However, you should be able to change the question so
that "OK" is suitable as the default. e.g. change "We will now buy
ourselves a porsche with your credit card, Do you want to continue with
this transaction OK Cancel" to "We will now buy ourselves a porsche with
your credit card, Would you like to abandon this transaction? OK Cancel"

Twice, porsche should be Porsche.

ISTR that someone recently proposed a method based on popping up a new
page with appropriate wording and buttons. If that works well, it
should be referred to and the code could be given in a Note.

Alternatively, ISTM that previously-hidden yes/no buttons on the base
page could be unveiled instead of using a confirm box. Of course, that
would not have the same modality.

<input type=button onClick="X.style.display='inline'; NO.focus()">
<span ID=X style="display:none background:red;"> ">
<input ID=NO type=button onClick="alert(0) ; X.style.display='none'">
<input ID=AY type=button onClick="alert(1) ; X.style.display='none'">
</span>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top