This topic is locked
[SOLVED]

 Show/Hide field if a multi-select lookup contains a certain value

2/2/2019 12:53:34 AM
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 had a workaround for the problem below phpRv9 which was...
To new a field in the DB called qualifications_OtherCheck and position it directly under the check box list on add/edit pages If checked, show qualifications_Other, else hide.
This solution worked great in V9 however in V10 I'm struggling to position the new field directly under the existing "qualifications_Other" to make it look like the same control to the user.
Therefore I'm wondering if anyone has a way to check to see if a multi-select lookup contains a certain value.
Many thanks
J

woodey2002 author 2/2/2019

With PHPRunner there is always a way.
Managed to sort this one, here is the solution...
Copy the v9 solution Jerry and I discussed in this forum post regarding checking if multi-select lookup contains a certain value.
Add the extra field as described for example lets call it otherCheck, and fire the Javascript off that checkbox.
You can then position the new otherCheck checkbox directly underneath the existing lookup to make it appear like it is a single control.
In V10 to move new otherCheck checkbox directly underneath the existing lookup use some custom CSS for the new otherCheck checkbox in the Custon CSS option for that control in the design tab.
Here the custom CSS that worked for me.
:host {

display:block;

margin-bottom:-1px;

margin-top:-15px;

position:relative;

}
Hope this helps.

J