This topic is locked
[SOLVED]

 Field events

6/5/2020 10:57:42 PM
PHPRunner General questions
rdf author

Hi PHPR community forum,
I am not sure what is wrong. I kept reading the Field events and the methods and applied what I read but it still doesn't work. Here's my scenario.
I have an Add form. In this form are:
Form number: C20001 (read only)
Date: 06/05/2020 (calendar control)
System: [C, P] (dropdown list)


Form number format: C20001

where C = system; 20 = 2-digit year; 001 = counter
If a user choose a system, the form number will change: if C chosen = C20001. If P chose = P20001.
If a user change the date to another year, form number will change: 06/05/2021 = C21001, 06/05/2019 = C19001.
I have code for the field event for both system and date field.
System field event->change->client before which is working.

params["system_id"] = this.getValue();


But, if I reference the system on the date field event->change->client before it is not getting a value:

var ctrl_system_id = Runner.getControl(pageid, 'system_id');

params["system_id"] = ctrl_system_id.getValue();


System and date field have default value set so it should get a value.
What seems to be wrong?

rdf author 6/6/2020

Hi Community,
Not sure what happened but when I tried referencing the system from the date field event->change->client before again, it now getting a value (confirmed by using an alert to popup the value).

var ctrl_system_id = Runner.getControl(pageid,'system_id');

params["system_id"] = ctrl_system_id.getValue();

alert(params["system_id"]);


The only fix I did is changing the date field properties->appearance to calendar dropdown boxes. And, to my surprise it worked.
I don't know why though...