This topic is locked
[SOLVED]

 Change fields on inline edit page based on another field

1/10/2012 12:29:17 PM
PHPRunner General questions
C
copper21 author

Hello,
Just a question regarding making fields "Read Only" or "Disabled" based on selection from dropdown box in the inline edit. I have a Master Table and from that Master Table is a Details Table that I have set up to edit as an inline edit. So when the user clicks on the Details link on the from the Master Table list page, I have the option to do an inline edit on the details table. The fields that I have shown in the details table inline edit are signup_status, ps, name, rank, appt_date, duty, report_to, datetime_report, instructions. The signup_status is a drop down box with the options "Pending, Accepted, Denied" Pending is the default, but the user would change the details record to accepted or denied. When the user changes the status to Accepted, I would like the fields duty, report_to, datetime_report, and instructions to remain open and editable. If the user selects denied from the drop down box, I would like to have those fields either disabled or read only preventing data to be inputed into those fields. The duty field is a drop down box, report_to is a lookup wizard from another table and is set up as a list page with search, datetime_report is a date/time field, and instructions is set up as a text area.
I put the following code into the "Javascript OnLoad Event" on the edit page of the details table:
edvar ctrlStatus = Runner.getControl(pageid, 'signup_status');

var ctrlDuty = Runner.getControl(pageid, 'duty');

var ctrlReportTo = Runner.getControl(pageid, 'report_to');

var ctrlDateTimeReport = Runner.getControl(pageid, 'datetime_report');

var ctrlInstructions = Runner.getControl(pageid, 'instructions');
ctrlStatus.on('change', function(e){

if (this.getValue() == 'Accepted'){

ctrlDuty.setEnabled();

ctrlDuty.addValidation("IsRequired");

ctrlReportT0.setEnabled();

ctrlReportTo.addValidation("IsRequired");

ctrlDateTimeReport.setEnabled();

ctrlDateTimeReport.addValidation("IsRequired");

ctrlInstructions.setEnabled();

ctrlInstructions.addValidation("IsRequired");

}else{

ctrlDuty.setDisabled();

ctrlDuty.setValue("");

ctrlDuty.removeValidation("IsRequired");

ctrlReportTo.setDisabled();

ctrlReportTo.setValue("");

ctrlReportTo.removeValidation("IsRequired");

ctrlDateTimeReport.setDisabled();

ctrlDateTimeReport.setValue("");

ctrlDateTimeReport.removeValidation("IsRequired");

ctrlInstructions.setDisabled();

ctrlInstructions.setValue("");

ctrlInstructions.removeValidation("IsRequired");
}});
I am getting an error when selecting the details table from the master list page. It states" Object doesnt support this property or method."
The other fields, ps, name, rank, appt_date are set to read only and do not need to be edited at any time.
I am using PHPRunner V 6.0 9948, IE 8, Windows XP
I used the example from this forum discussion and modified to fit my needs: Forum Link. I figured V 5.3 would have similar JavaScript as 6.0.
Thanks in advance for any assistance!

Sergey Kornilov admin 1/10/2012

The following looks like an error to me. Variable names are different.

ctrlReportT0.setEnabled();

ctrlReportTo.addValidation("IsRequired");
C
copper21 author 1/10/2012

Sergey,
Thanks seeing the error in my script; unfortunately, this did not solve the problem. I uploaded the project to the Demo area and opened up a ticket.

Sergey Kornilov admin 1/10/2012

Another thing is "edvar" in the beginning of the code you posted. Probably that supposed to mean "var".

C
copper21 author 1/11/2012

Sergey,
Feel stupid for not seeing that typo....all works! Thanks again!