473,387 Members | 1,362 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

custom text on 'confirm' popup buttons

Hi,
I wonder if it's possible to replace standard text on confirm-popup
buttons from 'ok' and 'cancel' to some other captions.
If not, is there a way to create quickly custom dialog, with only two
buttons, returning 'true' or 'false'? Would I have to use forms to
return value from my custom dialog?
Thanx for any help.
Jul 20 '05 #1
2 47627
dz***@wp.pl (dzeeq) writes:
I wonder if it's possible to replace standard text on confirm-popup
buttons from 'ok' and 'cancel' to some other captions.
It isn't.
If not, is there a way to create quickly custom dialog, with only two
buttons, returning 'true' or 'false'? Would I have to use forms to
return value from my custom dialog?


There are plenty, they just won't be modal (i.e., prevent you from
using the page while being shown). That also means that you can't
simply call it as a function that returns the user's choice. You will
have to get the answer from the click event instead.

The simplest is to have a <div> with two buttons, and show it when
needed. Something like:
---
<style type="text/css">
#confirmBox {
width:10em;
height:5em;
position:absolute;
z-index:1;
visibility:hidden;
background:blue;
color:white;
border:6px double white;
text-align:center;
}
</style>
<script type="text/javascript">
var answerFunction;
function myConfirm(text,button1,button2,answerFunc) {
var box = document.getElementById("confirmBox");
box.getElementsByTagName("p")[0].firstChild.nodeValue = text;
var button = box.getElementsByTagName("input");
button[0].value=button1;
button[1].value=button2;
answerFunction = answerFunc;
box.style.visibility="visible";
}
function answer(response) {
document.getElementById("confirmBox").style.visibi lity="hidden";
answerFunction(response);
}
</script>
...
<div id="confirmBox">
<p>Continue?</p>
<p><input type="button" onclick="answer(true)" value="Ok">
<input type="button" onclick="answer(false)" value="Cancel"></p>
</div>
<script type="text/javascript">
function tester(button) {
myConfirm("Say Aye or Nay!","Aye","Nay",
function(answer) {
button.value="Last answer was: "+(answer?"Aye":"Nay");
});
}
</script>
<input type="button" value="Answer me!" onclick="tester(this)">
---

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
"dzeeq" wrote on 13/11/2003:
Hi,
I wonder if it's possible to replace standard text on confirm-popup
buttons from 'ok' and 'cancel' to some other captions.
If not, is there a way to create quickly custom dialog, with only two buttons, returning 'true' or 'false'? Would I have to use forms to
return value from my custom dialog?
Thanx for any help.


If there is, it's either new (beyond v1.3 - I haven't caught up with
DOM yet), or browser-specific. You could use window.open to load a
small HTML page with two images, then set a global variable, or call a
function (better, so you don't have to poll), in the parent window.
Dirty, I know, but simple.

Mike

--
Michael Winter
M.Winter@[no-spam]blueyonder.co.uk (remove [no-spam] to reply)
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Andy Fish | last post by:
Hi, now I know what the alert() function does, but can anyone tell me where I can find the specification or standards for functions like alert() and confirm(). They don't seem to be part of...
3
by: Doug O'Leary | last post by:
Hey, all; Apparently, I'm missing the concept. I'm writing a web app in perl to manage nagios configuration files. One of the things I'd like to do is to confirm an update via a popup window...
2
by: Caesar Augustus | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
0
by: Stephen Adam | last post by:
Hi there, I am currently working on a custom web control which is a an editable text area. It exends the textbox class and will have four buttons, for adding a bold tag to selected text, adding...
4
by: tshad | last post by:
I am trying to fire the CustomValidator when I leave the Email field. Following is the code. It does PostBack, but the CustomValidator doesn't seem to be firing. <asp:TextBox...
9
by: Indu | last post by:
How can I customise something that a standard confirm() function gives us. I need to do something like if a user clicks on a link, a popup should say, "do you want to leave this page" and the...
1
by: rn5a | last post by:
I want to create a custom control that encapsulates a Button & a TextBox. When the Button is clicked, the user is asked a question using JavaScript confirm (which shows 2 buttons - 'OK' &...
0
by: rn5a | last post by:
A custom control is derived from the WebControl class & encapsulates a TextBox & a Button. When the Button is clicked, the user is shown the JavaScript confirm dialog with the 'OK' & 'Cancel'...
5
by: balakrishnan.dinesh | last post by:
hi Frnds, I need Confirm box with "yes" or "no" buttons, Is that possible in JAVASCRIPT , Can anyone tell me the solution for this or anyother way to create confirm box with "yes" or "no" button?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.