This topic is locked

How do I change the action of the Delete button

5/8/2008 9:06:35 AM
PHPRunner General questions
T
thesofa author

I have a list of all the workstations on the network, I would like to be able to send a Dos command to each of those that I select from the main list, either by filtering , or by selecting in the tick box.

My idea is that I select the stations, then click on the Delete selected button to send the command to the workstations concerned. The command has to contain the name of the workstation to be effective, in a fairly controlled format.

Where do I change the generated code to achieve this, or can I do this another more elegant way?
I have found/remembered the code from this post about the Same sort of question here, but I was wondering about the multiple send of code, where will that go and how do I do it?

Cheers

J
Jane 5/8/2008

Hi,
here are some tips:

  1. proceed to the Visual Editor tab
  2. turn on HTML mode, find this line:
    <!-- delete form -->



and add following code just before:

<A onclick="frmAdmin.a.value='update'; frmAdmin.submit(); return false;"

href="TableName_list.htm#">Your actions</A>



3. proceed to the Events tab and add BeforeDelete event.

Here is a sample code:

//delete records

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

return true;
//another actions

//ad your code here

return false;

M
michaelmac 10/15/2008

Support:
Will this snippet work with PHPR 5.0? I am trying to update a project in 4.2 to 5.0, and some of my old code is not behaving, so what do I need to change. The code above has always worked well for me.
Thanks
Mike

J
Jane 10/16/2008

Mike,
this code will work in the PHPRunner 5.0.

M
michaelmac 10/16/2008

hey everyone
Here is my tip back to the forum. I have only a couple, but this one applies to PHPR and I believe ASPR. I have been using a button I call "Process selected" as based off of Jane's script here. It has worked for me till I guess I got lost in PHPR 5.0. I found how to do the same thing, but I had to modify it it every so slightly. Here is my solution (hats off to Jane and the support staff for all their incredible workarounds)..

  1. Use the Visual Editor on any of your list pages (those ending in _list.php or _listasp) and click on one side or the other of where you want to place your "process selected" button. I typically reset the page so everything lines up nice and even. Then I go to the HTML side of where ever I have placed my cursor. You will see a list of {BEGIN process statements... I insert the following line of code:
    {BEGIN process_link}<SPAN class=buttonborder><INPUT class=button type=button value="Process selected" {$processlink_attrs}></SPAN>{END process_link} . I exit and Build it.
  2. I then go to that same _link.php or _link.asp page and open it up with my favorite editor and look for $xt->assign("delete_link",$allow_delete);
    I inserted the following code:
    $xt->assign("process_link",$allow_delete);

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

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

    frmAdmin.a.value = 'insert';

    frmAdmin.submit();

    return false;\"");
    right after the "return false;\"");" used in the delete_link block of code and right before else if (in PHPR 5.0)
    I saved this file and ran my app. It works just like before.
    In the event part.. $_POST['a'] is how I kept adding things.. when I test it I got 'insert' for my processing, that way I stayed true to Jane's reply.
    Happy Running!!!
    Mike

M
michaelmac 10/24/2008

hey everyone

Here is my tip back to the forum. I have only a couple, but this one applies to PHPR and I believe ASPR. I have been using a button I call "Process selected" as based off of Jane's script here. It has worked for me till I guess I got lost in PHPR 5.0. I found how to do the same thing, but I had to modify it it every so slightly. Here is my solution (hats off to Jane and the support staff for all their incredible workarounds)..

  1. Use the Visual Editor on any of your list pages (those ending in _list.php or _listasp) and click on one side or the other of where you want to place your "process selected" button. I typically reset the page so everything lines up nice and even. Then I go to the HTML side of where ever I have placed my cursor. You will see a list of {BEGIN process statements... I insert the following line of code:
    {BEGIN process_link}<SPAN class=buttonborder><INPUT class=button type=button value="Process selected" {$processlink_attrs}></SPAN>{END process_link} . I exit and Build it.
  2. I then go to that same _link.php or _link.asp page and open it up with my favorite editor and look for $xt->assign("delete_link",$allow_delete);
    and right after the return false;\""); in that delete block...
    I inserted the following code:
    $xt->assign("process_link",$allow_delete);

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

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

    frmAdmin.a.value = 'insert';

    frmAdmin.submit();

    return false;\"");
    right after the "return false;\"");" used in the delete_link block of code and right before else if (in PHPR 5.0)
    I saved this file and ran my app. It works just like before.
    In the event part.. $_POST['a'] is how I kept adding things.. when I test it I got 'insert' for my processing, that way I stayed true to Jane's reply.
    Happy Running!!!
    Mike

M
mattd1 11/2/2008

Hi Jane and Team
It would be extremely helpful to me (and everyone I think!) if you could give an updated version of how to get a button that behaves like "Delete Selected" but which we can customise the event code for ... It surely has got to be one of the most common requirements.
I've tried to follow the code provided above, and have various problems. Firstly:
(1) <!-- delete form no longer seems to apply (maybe it's {BEGIN delete_link} ?

(2) It only exists if the Delete Page is selected for the table
Then my current problem is that I have a MySQL view and I don't want to offer a DELETE option. Happy to use it though but simply return false if required. However, when I try this, the check-boxes are not shown for the rows in my list view (only the select all check-box column header).
The HTML code appears to include it, right next to my View link. But when I build then run, it's not there.
Can you help? What are the simplest steps I need to take to:
(a.) Add a button to the header area of the page

(b.) Maybe offer some confirmation prompt code prior to action (java script I guess)

(c.) Process the action

(c.1) Validate and possibly not proceed

(c.2) Proceed and do the action
Many thanks!
Matt

J
Jane 11/5/2008

Matt,
you can check off Delete page, then proceed to the Visual Editor tab, add new link just before {BEGIN delete_link} and remove delete button manually.