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