This topic is locked

Field event not working

4/14/2023 1:28:46 PM
PHPRunner General questions
T
Travnicanin author

Hi guys.
I cannot get result from query and input it in another field. There are so few examples on the net regarding this..
Client before:
params["value"] = this.getValue();
Server:
$myquery = "select Code from Measures where Code='".$params["value"]."'";
$rs2 = DB::Query($myquery);
$data2=$rs2->fetchAssoc();
$result["meas"] = implode($data2);
Client after:
var ctrlMeas = Runner.getControl(pageid, 'measID');
ctrlMeas.setValue($result["meas"]);
This doesn't work. If I change "ctrlMeas.setValue($result["meas"]);" into "ctrlMeas.setValue('10']);" = it is inputing 10 into measID control.
What am I doing wrong?

W
wedi 4/14/2023

I'm not sure and maybe I don't understand your query.
You select "Code" from a table with Code=xxx !?
Is it possible that you want to select a different column (for example "meas") from Measures where Code=.... ?
In that case I would use:
result["meas"] = $data2["meas"];
Regards,
wedi

fhumanes 4/15/2023

Hello,
It seems that you are encoding a custom button, with its 3 states. I think that is not the soluion you need.
The error is in this line:
"params["value"] = this.getValue();"
The reference to "this", in this context is wrong.
This example that I reference is not exactly what you need, but it is the architecture of the solution.
https://fhumanes.com/blog/guias-desarrollo/guia-44-pasar-valores-entre-ventanas-y-del-servidor/
Greetings,
fernando