This topic is locked
[SOLVED]

 Checkbox To Filter Listpage Results?

1/28/2013 8:26:36 PM
PHPRunner General questions
L
llager author

Im a newbie, but i wold like to add a checkbox to hidde inactive customer

i have in my table an row Active and Inactive but i would like to hide inactive customers on the list page is that possible??

thanks before hand!!

C
cgphp 1/29/2013

Yes, it's possible, but PHPrunner does not provide this sort of functionality. You have to implement a custom solution based on ajax call.

G
gdmacdo 1/29/2013

You could have 2 views. One for active and one for inactive. You could put a button called "View Active" on the inactive view. When it is clicked, it would take you to the active view and vice versa. On one of the views, you might list both active and inactive and in your Query page sort by one of the fields.



Im a newbie, but i wold like to add a checkbox to hidde inactive customer

i have in my table an row Active and Inactive but i would like to hide inactive customers on the list page is that possible??

thanks before hand!!


W
wildwally 1/29/2013

I ran into situations that I needed something similar to what your asking. I want to be able to filter different items based on the users input. I used the one approach provided already where you would create a custom view and a different Where statement built into the events. It works and nothing wrong with it until you have a lot of things your trying to do. In my case I want 5 different filter options and it could grow to more. So instead of creating multiple custom views I went about things a little differently.
I used a php snippet to create a drop down box with the value 1 thru 5 and the list represents the name of the filter. So in your example something with the options of:
"<option value='1'>Active Jobs</option>"
"<option value='2'>Inactive Jobs</option>"
Javascript to run an onchange and evaluate what the user selected if value =1 it

window.location ="ALLJobs_list.php?"

This would be your default page. However if they choose to see the Inactive Jobs the value would equal 2 and it would

window.location ="ALLJobs_list.php?opt=2"

Notice the variable in the url of opt=2.
The opt=2 comes into play with the List Page: before SQL query. Build a series of if statements in this event to evaluate the $_GET['opt'], something like this:



if(!$_GET['opt'])

{

$strWhereClause = "Jobstatus = 'Active'";

}

if($_GET['opt']==2)

{

$strWhereClause = "Jobstatus = 'Inactive'";

}


THis could be adopted to the check box idea that your looking for just need some javascript to change based on the value.
Hope this helps.

L
llager author 1/30/2013

THanks, It kinda worked , i just need learn a bit more, thanks every body!!



I ran into situations that I needed something similar to what your asking. I want to be able to filter different items based on the users input. I used the one approach provided already where you would create a custom view and a different Where statement built into the events. It works and nothing wrong with it until you have a lot of things your trying to do. In my case I want 5 different filter options and it could grow to more. So instead of creating multiple custom views I went about things a little differently.
I used a php snippet to create a drop down box with the value 1 thru 5 and the list represents the name of the filter. So in your example something with the options of:
"<option value='1'>Active Jobs</option>"
"<option value='2'>Inactive Jobs</option>"
Javascript to run an onchange and evaluate what the user selected if value =1 it

window.location ="ALLJobs_list.php?"

This would be your default page. However if they choose to see the Inactive Jobs the value would equal 2 and it would

window.location ="ALLJobs_list.php?opt=2"

Notice the variable in the url of opt=2.
The opt=2 comes into play with the List Page: before SQL query. Build a series of if statements in this event to evaluate the $_GET['opt'], something like this:



if(!$_GET['opt'])

{

$strWhereClause = "Jobstatus = 'Active'";

}

if($_GET['opt']==2)

{

$strWhereClause = "Jobstatus = 'Inactive'";

}


THis could be adopted to the check box idea that your looking for just need some javascript to change based on the value.
Hope this helps.