Home News Contact Us Forum About Us Demos Products F.A.Q.
Shopping Cart
You currently have 0 items in your cart.


Recent Events
  • 23/11/2024 Black Friday 2024

    BIG SALE, 30% discount for all our extensions. Use BF24 coupon code. Hurry up the discount is valid till 3 December.

  • 31/12/2023 New Year SALE

    We are glad to announce New Year SALE. 25% discount for all our extensions. Use NY24 coupon code. Hurry up the discount is valid till 7 January.


2Checkout.com, Inc. is an authorized retailer of goods and services provided by ARI Soft. 2CheckOut




Follow us on twitter



Welcome, Guest
Please Login or Register.    Lost Password?

How to filter table by a dropdown list
(1 viewing) (1) Guest
Go to bottomPage: 12
TOPIC: How to filter table by a dropdown list
#43450
How to filter table by a dropdown list 11 Years, 3 Months ago Karma: 0
Hi,
I need to show a table, filtered by the value of a dropdown list (comboUserID) that is automatically filled when the page is loaded.

So I fill this listbox using a jumi script in php, which reads from a db and "echos" a form containing the dropdown list(<select id='comboUserId'... />) within the article.

Then I want to use the mod_aridatatables module to show only the records of my table where userID = the selected entry of comboUserId.

Now I know how to filter by a variable "prepared" in class.DataTablesDataSqlModel, or using a GET/POST value ({REQUEST:$comboUserID}).

But the point is that when the form is loaded the 1st time, no value is posted.

I'd love to configure the SQL query of the mod_aridatatables using something like "SELECT * FROM ORDERS WHERE USERID={REQUEST:$comboUserID}", however this does not work when the form is loaded for the 1st time.

What's the right practice to accomplish this standard behaviour?

Thanks in advance,

Mauro
The administrator has disabled public write access.
 
#43453
Re:How to filter table by a dropdown list 11 Years, 3 Months ago Karma: 760
Hello,

Use the following SQL query:

SELECT
*
FROM
ORDERS
WHERE
({$REQUEST:comboUserID|empty:''} = '' OR USERID={$REQUEST:comboUserID|empty:''})

Regards,
ARI Soft
The administrator has disabled public write access.
 
#43454
Re:How to filter table by a dropdown list 11 Years, 3 Months ago Karma: 0
Hi,
thanks for your answer. I'm afraid I didn't explain well.

The point is that {REQUEST:$comboUserID} is seen BLANK by the ARI module when the page is loaded the first time, because the page is loaded through a link of menu item (mysite/index.php/myorders) and thus no POST/GET variables are set. However, as said I build the dropdown list and I select one entry during the page loading.

So I need that the ARI module "reads" the variable from the drop down list control that is on the page, rather than from a POST variable because no POST variables are set.

Of course, if I do a SUBMIT of this page on itself, the next time the ARI module CAN retrieve the drop down list entry through {$REQUEST:comboUserID}. But I need it does it even for the 1st page loading.


Thanks

Mauro
The administrator has disabled public write access.
 
#43460
Re:How to filter table by a dropdown list 11 Years, 3 Months ago Karma: 760
Do you want to specify a default value if "comboUserID" request variable it not defined?

Regards,
ARI Soft
The administrator has disabled public write access.
 
#43462
Re:How to filter table by a dropdown list 11 Years, 3 Months ago Karma: 0
By definition, a combo box is always set. So it is for this one, which is initialized during the form load event. Then I use a PHP script to choose which entry should be selected within the combo box. So I must read that value, maybe with something like document.myForm.comboUserID.options[document.myForm.comboUserID.selectedIndex].value.

I even tried to set $_POST["comboUserID"] within the same PHP script, however this value is not ready by the ARI module when it tries to read it.

Thanks,

Mauro
The administrator has disabled public write access.
 
#43472
Re:How to filter table by a dropdown list 11 Years, 3 Months ago Karma: 760
Could you provide a link to a page where you use the extension and a temporary access to your J! backend by email so we can try to help modify PHP code which is used in JUMI?

Regards,
ARI Soft
The administrator has disabled public write access.
 
Go to topPage: 12