This topic is locked

Reason for deletion input before record deleted

12/22/2008 10:09:28 AM
PHPRunner General questions
S
Stettin author

Is there a way to prompt for a reason for deletion before a record is deleted? I've already set up my table row to be copied over to another table before deletion, however the "history" table has two additional fields: date deleted, reason for deletion. I've used the NOW() function to insert the date for deletion, but don't see a way to ask for and insert the reason for deletion. I'd really like to avoid adding the deletion reason field to the original table, because it would look a bit messy. Any ideas?
I've tried using a form inside the before deletion function to post to itself, but it just restarts the whole list.php page, not just the function.
Ideally, it would be nice to ask for the reason for deletion at the same time the popup for "Do you really want to delete these records"

J
Jane 12/23/2008

Hi,
unfortunately there is no easy way to insert a reason for deletion.

This task can be accomplished using custom JavaScript code. However we don't have a ready to go solution for this.

S
Stettin author 1/2/2009

Hi,

unfortunately there is no easy way to insert a reason for deletion.

This task can be accomplished using custom JavaScript code. However we don't have a ready to go solution for this.


I don't mind putting in some custom code, because this project won't really need to be edited much in the future. I can handle keeping track of one manual edit. I've got this working, but I'm not sure how to assign the "reason" to a PHP variable so it can make it to the BeforeDelete function. Can you help with that?

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

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

var reason = prompt('Reason:','');

// If reason is not empty string, do something

frmAdmin.submit();

return false;\"");
S
Stettin author 1/6/2009



I don't mind putting in some custom code, because this project won't really need to be edited much in the future. I can handle keeping track of one manual edit. I've got this working, but I'm not sure how to assign the "reason" to a PHP variable so it can make it to the BeforeDelete function. Can you help with that?

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

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

var reason = prompt('Reason:','');

// If reason is not empty string, do something

frmAdmin.submit();

return false;\"");



Sorry about the bump, but I'm still trying to figure out how to do this...

J
Jane 1/7/2009

Hi,
this task is more complicated then to add simple promt to the actual code.

Here are some tips:

  • replace JavaScript action for Delete button with your own code,
  • create small popup window where user will enter reason for deletion,
  • save and pass it to the main window and then submit form in the main window manually.

    However we don't have a ready to go solution for this.