Set input value based on dynamic input name saved in variable

I have a need for something more complex than a regular autocomplete can do and below is what I have that works. Hopefully someone can help me figure out how to make it more dynamic so I don’t have to create a new table list for each instance this feature is needed.

The user needs to be able to simply type in a name and be done or click the “Search” icon and can select from a list of contacts. I have two fields. The one on top is what the user will see, the one below will be hidden and is what is saved to the database.

As the user types, the bottom field mirrors the top field but if the user clicks on the “Search” icon a modal pops up so they can search for a particular contact. Upon selecting the contact, the bottom field gets populated with the selected contact’s id and the top field gets populated with the name and the modal closes. This works great because when I do the on click event for the table row I chose the inputs using the data picker so it knows exactly which inputs to put the values into.

What I’d like to do is when the user clicks the “Search” icon the name of the top and bottom inputs get saved into two different variables and those variables are read when the user clicks on a table row to select a contact which in turn fills in the proper inputs based on those saved names in the variables.
Another approach would be to dynamically set a class on each input like “id_input_to_fill” “name_input_to_fill” and have the row click look for those?

I can’t see a way to tell the click event to use the variables as the input names. Is this possible using the Wappler UI?

Thanks in advance.

Dynamic Event > Mouse > Click > Set Value > var
(repeat for 2nd var)

dmx-bind:name="{{var.value}}"

Actually you can just use regular repeat however you like and (for example) set your table id to 0 if there's no input filter gets in. Then use dynamic attribute to set any value from the repeat to your form input.

Thanks for the reply @transcoderm I’ll give these a shot when I get a chance.

I did a quick test and because the Wappler variable ids need to be unique it’s not going to work the way I need. I was trying to avoid using good ole PHP to make it dynamic and do it the Wappler way if possible but not sure it can do something like this without php:

<?php $column_name = 'some_column';?>
<input  id="inp_<?php echo  $column_name;?>" name="<?php echo  $column_name;?>" 
dmx-bind:value="detail_inpections.data.<?php echo  $column_name;?>" >

Course that is a simplified version of the lookup field I created but that’s the idea. I plan to include the field various places and before each include place <?php $column_name = 'some_column';?> and set the $column_name to the name of the next input and so on.

Yes you can. BTW why do you need multiple inputs? If I understand correctly all you need to achieve is an extended version of auto complete. How many inputs do you need to have for this thing. You can use Wappler’s data detail to get the selected value to your target input or use JavaScript to set the input value based on selected element value or whatever. Sorry if I didn’t fully understand what you actually need to achieve here. :sweat_smile:

@transcoderm I look at my original post and I probably should have made my last post with the PHP in it the original post haha. I can see why you’re confused on what I’m trying to do as I jumped around a bit…lol
I appreciate the response. I think the PHP way will work for now cause I have a meeting with the client tomorrow afternoon and need to have this finished by then.