473,394 Members | 1,866 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,394 software developers and data experts.

confirm update popup?

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:

function confirm_update()
{ var width = 400;
var height = 300;
var Rc = false;
var left = parseInt((screen.availWidth/2) - (width/2));
var top = parseInt((screen.availHeight/2) - (height/2));
var winFeatures = "width=" + width + ",height="+height +
",status,resizable,left="+left+",top="+top+
",screenX="+left+",screenY="+top;
var cwin = window.open("","confirm_update", winFeatures);
var ncontent="<html><head><title>Confirm update</title>"
ncontent += "</head>"
ncontent += "<body><h1>Confirm Update</h1>";
ncontent += "<table align='center'><<tr>>";
ncontent += "<<td>><button ";
ncontent += " onclick='window.close(); return true'>";
ncontent += " <big>Confirm</big></button>";
ncontent += "<<td>><button ";
ncontent += " onclick='window.close(); return false'>";
ncontent += " <big>Don't do it!</big></button>";
ncontent += "</<tr>></table></body></html>";
cwin.document.write(ncontent);
cwin.document.close();
}

And it's called via the onclick method in the submit button:

<button type="submit" onclick="return (confirm_update())">
<big>Update</big></button>

I've played with this a couple of different ways. The window pops up
like it's supposed to. I can get the function to always validate or
always fail; however, it's never based on the button press.

I know this is because the function is returning before the user even
sees the confir/refute buttons much less presses one of them. I'm
obviously much more used to procedural languages and just can't quite
wrap my brain around a stateless protocol.

I would think this would be a fairly common function. Can someone
point me to some code snippets that would get me started on the right
path?

Thanks for any hints/tips/suggestions...

Doug O'Leary

--

--------
Senior UNIX Admin
O'Leary Computer Enterprises
dk******@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume: http://home.comcast.net/~dkoleary/resume.html
Jul 23 '05 #1
3 2819
Lee
Doug O'Leary said:

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:

function confirm_update()
{ var width = 400;
var height = 300;
var Rc = false;
var left = parseInt((screen.availWidth/2) - (width/2));
var top = parseInt((screen.availHeight/2) - (height/2));
var winFeatures = "width=" + width + ",height="+height +
",status,resizable,left="+left+",top="+top+
",screenX="+left+",screenY="+top;
var cwin = window.open("","confirm_update", winFeatures);
var ncontent="<html><head><title>Confirm update</title>"
ncontent += "</head>"
ncontent += "<body><h1>Confirm Update</h1>";
ncontent += "<table align='center'><<tr>>";
ncontent += "<<td>><button ";
ncontent += " onclick='window.close(); return true'>";
ncontent += " <big>Confirm</big></button>";
ncontent += "<<td>><button ";
ncontent += " onclick='window.close(); return false'>";
ncontent += " <big>Don't do it!</big></button>";
ncontent += "</<tr>></table></body></html>";
cwin.document.write(ncontent);
cwin.document.close();
}

And it's called via the onclick method in the submit button:

<button type="submit" onclick="return (confirm_update())">
<big>Update</big></button>

I've played with this a couple of different ways. The window pops up
like it's supposed to. I can get the function to always validate or
always fail; however, it's never based on the button press.

I know this is because the function is returning before the user even
sees the confir/refute buttons much less presses one of them. I'm
obviously much more used to procedural languages and just can't quite
wrap my brain around a stateless protocol.

I would think this would be a fairly common function. Can someone
point me to some code snippets that would get me started on the right
path?


If you want submission to depend on the return value of
an event handler, use the onSubmit event handler of the
form, not the onclick handler of the submit button.

Your function confirm_update() doesn't return a value, so
"return confirm_update()" isn't going to control anything.

The window has a confirm() method that does what you want:
<form name="whatever" ... onsubmit="return confirm('Update?')">

Jul 23 '05 #2
Doug O'Leary wrote:
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.
A much simpler 'confirm' dialog is:

<form ... onsubmit="return confirm('Do update?');">

Zero issues with pop-up blockers (some block requested pop-ups too).

[...]
I know this is because the function is returning before the user even
sees the confir/refute buttons much less presses one of them. I'm
obviously much more used to procedural languages and just can't quite
wrap my brain around a stateless protocol.


Using a 'confirm' dialog gives you a modal dialog.
[...]
--
Rob
Jul 23 '05 #3
On 2005-06-26, Lee <RE**************@cox.net> wrote:

The window has a confirm() method that does what you want:
<form name="whatever" ... onsubmit="return confirm('Update?')">


Lee and Rob, thanks. That's exactly what I was looking for.
Simple and elegant... Too cool. Thanks again.

Doug

--

--------
Senior UNIX Admin
O'Leary Computer Enterprises
dk******@olearycomputers.com (w) 630-904-6098 (c) 630-248-2749
resume: http://home.comcast.net/~dkoleary/resume.html
Jul 23 '05 #4

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

Similar topics

7
by: Tasha's Dad | last post by:
A description of the problem: 1) Go to a page with various settings and a timeout (forces re-login if over 10 minutes) 2) Before the timeout, make some changes to settings. 3) Press a "reset to...
2
by: Hans | last post by:
Hi! I have an asp application where I use a lot of javascript for validations etc and as it is today I use alert, confirm and prompt dialogs. Now we are adding support for unicode and I have...
1
by: Sandy | last post by:
I have a repeater which shows Group names. (Skip this part if you want rather irrelevant) The groups are ordered and formatted: Parent ---Child ------Grand Child (okay start reading again...
0
by: aaa | last post by:
I am at my wits end I an trying to pass a couple of values to a page with a UC (parent) from a popup (child). But only after a JS confirm on the child popup. Seems straight forward. I have only...
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...
17
by: Chris Ianson | last post by:
Hi, I have this JavaScript, which I only want to occur if a user clicks on a hyperlink hotspot in a large image: <script type="text/javascript"> <!-- var answer = confirm ("This link is not...
4
by: ChrisA | last post by:
I need to get the user to confirm a button push/postback with a popup from the browser, in ASP.NET 1.1. What's the right way to wire that up?? Thanks
3
by: OccasionalFlyer | last post by:
I have become owner of some Javascript code that displays a message through the confirm() function. I have a uwser reuqest to make the font size of this message larger. Can this be done? I don't...
4
by: Arnab das | last post by:
Below is the javascript code i am using function confirmDelete() { var returnValue = window.confirm("Deleting the current page. Continue?"); return returnValue; // var...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.