Change Lookup-Value on the fly

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
digitalphotoworld
User
Posts: 416
Location: Nürnberg/Germany

Change Lookup-Value on the fly

Post by digitalphotoworld »

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.


arbei
User
Posts: 9286

Post by arbei »

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.


kirondedshem
User
Posts: 642

Post by kirondedshem »

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.


Post Reply