Page 1 of 1

deleting a file with a confirmation pop up

Posted: Mon Sep 08, 2003 10:55 pm
by wesnoel
ok so I know how to delete a file from a dir.

...but what if I make a mistake and delete the wrong file?

Is there way to have a pop up ie. javaScript or something like that, that says are you sure you want to delete this file.

The delete script I am using is:

Code: Select all

<?php
if(isset($del)){
unlink("$del");
}
?>
and the link to that is:

Code: Select all

&lt;a href="index.php?del=files/$file" target="_self"&gt;DELETE&lt;/a&gt;

How can I add that confirmation pop up?

Any help would be apreciated.

TIA,


Wes

Posted: Mon Sep 08, 2003 11:08 pm
by m3rajk
yes.

Code: Select all

onClick="alert('Are you sute you want to continue?');"
added to the link will then pop up an alert before going through

Posted: Mon Sep 08, 2003 11:59 pm
by wesnoel
thank you for that idea but I couldn't get that to work.

Back to the drawing bord.

:D

Wes/

Posted: Tue Sep 09, 2003 2:58 am
by JayBird
try this, you need to use confirm instead of alert

Code: Select all

<a href="index.php?del=files/$file" target="_self" onClick="confirm('Are you sure you want to continue?');">DELETE</a>
Mark

Posted: Tue Sep 09, 2003 10:06 am
by m3rajk
that right. alert doesn't give you a way to back out.