473,569 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 47651
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:absolu te;
z-index:1;
visibility:hidd en;
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.getEle mentById("confi rmBox");
box.getElements ByTagName("p")[0].firstChild.nod eValue = text;
var button = box.getElements ByTagName("inpu t");
button[0].value=button1;
button[1].value=button2;
answerFunction = answerFunc;
box.style.visib ility="visible" ;
}
function answer(response ) {
document.getEle mentById("confi rmBox").style.v isibility="hidd en";
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","Na y",
function(answer ) {
button.value="L ast 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/rasterTriangleD OM.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.u k (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
18434
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 the ECMAScript language but aren't part of the DOM either. Now we seem to be finally reaching a stage of standards-compliant browsers, there seems to...
3
2831
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 prior to writing out changes. My first whack at that goal isn't working out too well. I have the following javascript in one of the pages:
2
3406
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 controls (i.e. roundedcorners component www.4guysfromrolla.com], buttons and panels) functions like a tab control. The buttons are programmatically...
0
881
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 italic tag to selected text, adding a hyplink tag to selected text. These are all quite easy just using some javascript to add some set text to the...
4
8890
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 AutoPostBack="true" Columns="45" ID="email" runat="server" TextMode="SingleLine" /> <asp:CustomValidator ControlToValidate="email" OnServerValidate="ValidateEmail"...
9
13999
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 buttons that we need is "yes - no" instead of "ok - cancel". I tried doing it with window.open() but without any success. I couldn't figure out how to...
1
3202
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' & 'Cancel'). Till this point, no problem. Initially, the TextBox is empty. The Button has a property named 'ConfirmMessage' so that the developer using this...
0
1383
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' buttons. If the user clicks 'OK', the TextBox gets populated with 'true' & if 'Cancel' is clicked, the TextBox gets populated with 'false'. Note that...
5
28235
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? Thanks & Rgrds Dinesh...
0
7698
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7970
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.