Change Lookup-Value on the fly

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.

Change Lookup-Value on the fly

Postby digitalphotoworld » Tue Jan 09, 2018 4:23 pm

Is there a way to change the lookup-value on the fly?

Example:
I have a select list with 4 items
- car
- motor-bike
- bicycle
- boat

Now I want to change the value "car" to "MERCEDES" and "motor-bike" to "HONDA" is this possible?

Or is it possible to change the select-part of the lookup-query? With Lookup-Selecting Event I can only change the WHERE part of the query.
digitalphotoworld
 
Posts: 386
Joined: Wed Jan 09, 2013 12:26 am

Re: Change Lookup-Value on the fly

Postby arbei » Wed Jan 10, 2018 11:18 am

If you mean you need to update the options of the lookup field, you can subscribe the "addoption" event, and update the data for each item.

For example:
$(document).on("addoption", function(e, args){
console.log(args); // show the content to console.
args.data[2] = "display field 2"; // Update the value of display field 2.
}

>> Or is it possible to change the select-part of the lookup-query? With Lookup-Selecting Event I can only change the WHERE part of the query.
It is not possible.
arbei
 
Posts: 1491
Joined: Wed Sep 09, 2015 10:13 am

Re: Change Lookup-Value on the fly

Postby kirondedshem » Wed Jan 10, 2018 1:29 pm

>Now I want to change the value "car" to "MERCEDES" and "motor-bike" to "HONDA" is this possible?

Ive been In a case where I had to use two different lookup settings fro the same field depending on a given condition. I was able to come up with a dirty way around it, something like.

1. You can use sql operator "UNION" to join two lookup settings and maybe add an extra filed to filter out which lookup setttings belong to which one. Then after YOu can setup parent child lookup where depending on what is selected the lookup will only contain the lookup values of a specific lookup setting.
2. You can also create a dummy custom fields, and setup different lookup settings for them. And depending on what you condition is you only show the field whose lookup setting matches what you want to use at that time. Here you can even switch between any at run time or using jquery

>Or is it possible to change the select-part of the lookup-query? With Lookup-Selecting Event I can only change the WHERE part of the query.

So explain in details which lookup settings you want to setup and how diffrene tthey are from each other, as well as under what conditions do you want to switch from one to the other. With as much detail as possible, then maybe we can help you come up with an alternative.
kirondedshem
 
Posts: 313
Joined: Sat Jan 28, 2017 7:13 pm


Return to General Discussion (PHPMaker)