You are viewing limited content. For full access, please sign in.

Question

Question

populate drop down from lookup and retain list values

asked on July 26, 2021

I see this question has been asked before and hate having to ask again, but I haven't found the solution.

I have a drop down field on a form that is set with a list of values.  It is being populated by a lookup, however, I'd like the submitter to be able to change to another value in the list.

When the the "Append choices to lookup results" is not set, I get the value from the lookup, but not the other list values.

 

And when the "Append choices to lookup results" is set, I do not get the value from the lookup, but do get the list values.

 

I have gotten this to work when the drop down field was on a table, but in this case I'm not using a table.  Hoping I'm just doing something wrong!

We are currently on version 10.4.3.216 of Forms, and any ideas will be appreciated!

Thanks!

 

0 0

Replies

replied on July 26, 2021 Show version history

You can't really use a lookup to "set" the value of a dropdown like you do with other field types, that will only set the "list" of values.

When there is only one result value, it is essentially the same since it auto-selects the only value available, but what it is really doing is populating the list of options not setting a specific value.

I imagine the reason it doesn't look like your Append selection is doing anything is because I believe there is some built in functionality to prevent duplicate options.

If you want to preserve the list and auto-select a value in a dropdown using the results of a lookup, then you'll need to utilize a separate hidden field.

Basically, create a hidden single line field that receives the lookup result value, then add JavaScript that will "transfer" that value to your dropdown whenever it changes.

for example,

$(document).ready(function(){
   $('.myLookup input').on('change', function(){
       $('.myDropdown select').val($(this).val()).change();
   });
});

 

1 0
replied on July 27, 2021

I really appreciate the answer and will do it this way.  I do think this is one that Laserfiche needs to get working because of the inconsistency that it works on a drop-down on a table but not a standard drop-down field.  This is likely because of the "as new rows" option available with table lookups.

Thanks again!

0 0
replied on July 27, 2021

The behavior is technically consistent on a table but like you suspected the "add as new rows" option is what causes the difference you're seeing.

In your case a table does what you want because there is only one result so "add an new rows" doesn't actually do anything other than prevent the overwrite.

However, if you had more than one result from the lookup the add as new rows option would spread those results out and things would be very different.

It's all kind of a balancing act of what's the "most common" use case, but I agree it would be nice to be able to choose the behavior.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.