This topic is locked

Adding two buttons to the list page.

5/4/2008 12:34:32 PM
PHPRunner General questions
F
fsteves author

Right now I want to be able to run the following query against the WHERE statement generated much like Delete Selected, in two buttons like Accept Selected, Deny Selected:
I have added the buttons with this:

<SPAN class=buttonborder>

<INPUT class=button onclick="if (confirm('Do you really want to accept these records?')) frmAdmin.Submit(); return false;" type=button value="Accept selected" name="acceptsel" disptype="control1">

</SPAN>

&nbsp;

<SPAN class=buttonborder><INPUT class=button onclick="if (confirm('Do you really want to deny these records?')) frmAdmin.Submit(); return false;" type=button value="Deny selected" name="denysel" disptype="control1">

</SPAN>


if (@$_REQUEST["acceptsel"])

{



$strSQL = "UPDATE `submissions` SET status = 'Accepted' where ". $where;

}

if (@$_REQUEST["denysel"])

{

$strSQL = "UPDATE `submissions` SET status = 'Denied', rejected = '1' where ". $where;

}


I dont know how to go about making this work, apart from creating nested forms and my own custom queries inside of NEW pages based off the list code. But, you can nest forms that way, as the first form will be the only one that can Submit. Can anyone help?

J
Jane 5/5/2008

Hi,
try to use following code on the Visual Editor tab:

<INPUT class=button onclick="if (!confirm('Do you really want to accept these records?')) return false; frmAdmin.a.value='accept'; frmAdmin.submit(); return false;" type=button value="Accept selected" name="acceptsel" disptype="control1">


Then add your code to the BeforeDelete event on the Events tab. Here is a sample:

//delete records

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

return true;
global $conn;
//accept

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

{

$strSQL = "UPDATE `submissions` SET status = 'Accepted' where ". $where;

db_exec($strSQL,$conn);

}
return false;