This topic is locked
[SOLVED]

 show/hide lookup wizard checkbox list.

2/22/2018 4:13:22 PM
PHPRunner General questions
woodey2002 author

Hi Guys,
On my add page I have a have a field call "qualifications"
This field is set to a lookup wizard of the qualifications table
The lookup wizard is set to a checkbox list, which also allows multiple selection of values.
I have added a javascript onLoad event to show/hide a field called "qualifications_Other" if "Other" is selected from the "qualifications" lookup wizard checkbox list control.
Here is the javascript onLoad code:
//Start.............................................................................

var ctrlIvcX841 = Runner.getControl(pageid, 'qualifications');

var ctrlIvcX841T = Runner.getControl(pageid, 'qualifications_Other');
pageObj.hideField("qualifications_Other");
ctrlIvcX841.on('change', function(e) {
if (this.getValue()!= "Other"){
pageObj.showField("qualifications_Other");

ctrlIvcX841T.addValidation("IsRequired");

}
else {
pageObj.hideField("qualifications_Other");

ctrlIvcX841T.removeValidation("IsRequired");

ctrlIvcX841T.setValue('');
}

});

//End.............................................................................
This event works well if the exact value ONLY is selected by the user,
However because the user can select multiple values, if a user selects more than one value from the "qualifications" lookup wizard checkbox list control, the show/hide process is broken.
I was just wondering if possible can I change the operator or something to show or hide the field even if MULTIPLE values ("Other" being the trigger value) are selected in the"qualifications" lookup wizard checkbox list control?
i.e. if (this.getValue()== "Other"){
Many thanks

jadachDevClub member 2/22/2018

I tried doing the same thing but could not get it to work. Here is what I did.
Add a new bit field in the DB called qualifications_OtherCheck and position it directly under the check box list on your add/edit pages. Now you can focus on that one field for your JavaScript. If checked, show qualifications_Other, else hide.
If someone has a better way, I look forward to seeing it.

woodey2002 author 2/22/2018

Many thanks Jerry!
That done the trick.
Cheers