This topic is locked
[SOLVED]

 Add alert box before confirm box for 'Delete selected' butto

3/16/2009 11:44:33 PM
PHPRunner General questions
L
laonian author

I am using PHPR version 5.0 Build 766. I have a table that can be accessed by different users. The records are set so that they are editable by different users, but can be deleted only by the user who created (added) it. The ownership info of the record is stored in the field "owner". To prevent the records to be deleted by other users, I tried to add a BeforeDelete event (alert box) on List page:

if(@$_POST["a"]=="delete")

{

if ($deleted_values["owner"]!=@$_SESSION["UserID"])

{

echo "<script>alert('You cann't delete other people's records!')</script>";

return false;

}

else

return true;

}



The code did not work.
Then I checked the _list.php file and guess perhaps I could do the alert by modifying the default deletion confirmation line found at:

$xt->assign("deletelink_attrs","onclick=\"

if(\$('input[@type=checkbox][@checked][@name^=selection]').length && confirm('"."Do you really want to delete these records?"."'))

frmAdmin.submit();


What I want to add isan if/else statement between onclick=\" and if(\$('input[@type=...... But I am a javascript newbie. Could someone "convert" my PHP coding into javascript and insert it in between for me, if it makes any sense at all? Thanks.

J
Jane 3/17/2009

Hi,
you need to use BeforeDelete event to prevent to delete records.

You can publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error and I'll try to help you with this code.