You're so negative, Jason. :)

Long answer, Dave, it wouldn't be wise to do this via Javascript. Javascript
can be turned off and also varies from browser to browser (like any
client-side language/scripting), so this raises an issue of reliability. You
may be able to do it if you're working on an intranet where you know that
all users have the same browser, have Javascript turned on, and don't have
access to turn it off, OR if this is for your own use and you don't want to
make it screw up. Otherwise, it might be a nice feature, but you shouldn't
rely on it.

If you WERE going to do it, I would have your main form have a hidden input
called "Confirm" and set it to a value of 1. Then, have a "Button" (not a
submit button) use Javascript to open a new browser/popup window (you can
format it to look like a regular Yes/No windows popup box). Have the "Yes"
I-want-to-delete-this-record button change its parent window's form and
change the "Confirm" input's value to 0 and submit the parent window's form
in order to delete the record. Have the No button just close the popup/new
window.

Now, on the page that actually deletes the record, first check the Confirm
variable. If it is set to 0, then you can figure that the Javascript set it
to 0, and you can go ahead and delete the record without asking. Otherwise,
show a regular HTML screen that asks if you really want to delete this
record (no Javascript this time), so you can be covered if Javascript gets
turned off. 

This is by no means a fool-proof method, and you should think carefully
through all this before implementing a Javascript solution, but I find that
there are better methods with PHP. For instance, you can have 3 checkboxes
side-by-side that can act as the
"yes-I-really-really-want-to-delete-this-record" safety. PHP can check to
see if all 3 checkboxes were checked, and then you can know that the user
was intentionally trying to delete that record, and you can go ahead and
delete it - no Javascript needed. :)

As far as the Javascripting goes, though, I would check out some JS forums
for help on how to set up the actual scripting part of the popup box. But,
as Jason probably was thinking, Javascript is never a very good thing to use
with things that are delicate, fragile, or valuable in any way. It's like
hiring an ex-thief to help you move - you can never be SURE that
everything's going to be there in the end.

- Jonathan

-----Original Message-----
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 01, 2002 12:45 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Pop up are you sure...


On Monday 01 April 2002 16:44, Dave Carrera wrote:
> Hi All
>
>
>
> How do you do this?

Use javascript.

> On click of button to delete a record make a popup yes / no box appear.
> On yes then do it else stop.
>
>
>
> Is it possible to do with out using JS?

Short answer, no.


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
Timing must be perfect now.  Two-timing must be better than perfect.
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to