This topic is locked
[SOLVED]

 How can I use a java script variable in Where at Lookup Wizard

9/27/2017 11:01:30 AM
PHPRunner General questions
G
gustavo author

I would appreciate some help about how to use a java script variable into the WHERE statement in a Lookup Wizard on the ADD Page

This is the case.

On ADD page the user switches Power Units from hp to kW.

Based on selected units, the Lookup Wizard would look up in a table for WHERE 'Units' is = 'Selected units'

Code on JavaScript Onload Event on ADD page

var ctrlPower_u = Runner.getControl(pageid, 'Power_u');

var jsPowerUnits = ctrlPower_u.getValue();

alert ('jsPowerUnits is : '+jsPowerUnits);



Code on Where on Lookup Wizard

" `Units` = 'jsPowerUnits'"

The lookup is returning no records.

My first approach was to find a way to pass the variable from Java Script to PHP as a session variable and then use the session variable in the lookup wizard on where statement.

Is it possible to pass a variable from Java Script to PHP from Java Script On load Event?

Look forward for your suggestions and ideas about how to accomplish this lookup

Thank You

Sergey Kornilov admin 9/29/2017

There is a flaw in this logic. Javascript OnLoad event happens once when page is loaded, before user has a chance to change any values.
What you need to use here is 'Field events':

https://xlinesoft.com/blog/2017/07/25/using-field-events/

G
gustavo author 10/5/2017



There is a flaw in this logic. Javascript OnLoad event happens once when page is loaded, before user has a chance to change any values.
What you need to use here is 'Field events':

https://xlinesoft.com/blog/2017/07/25/using-field-events/



Thank You Sergey

Gus