Zipcode text input autocompletes with city

Hello, I made an app to create waybills with an api of a packaging company, I already have it working and I made some text inputs to modify the json body that is sent to create the waybill, what I want to do is that when you put the zip code in the zip code text input it autocompletes the city text input with its respective city, I made a table in retool database with the zipcode as primary key with its respective city in the other column but I do not know how to achieve that when I put the zip code it autocompletes the city in its text input

Hi @Juan_Carlos_Ortiz

Would a solution like this work?

I have an event that triggers on blur of the zip code input. It searches my query for that zip code and then sets the city text input to be equal to the corresponding city:

If this doesn't quite fit your use case, please let me know & I'll take another look!

Hello! thanks for your answer but there are some things I don't understand, first you are getting the data by a javascript query but I have my table in retool database and the query looks like this

I don't know how to apply the blur handler.

Hi @Juan_Carlos_Ortiz the blur event handler would be added to the zip code component. It will trigger when you click out of the zip code input

Apologies for the confusion with the JS query! I was just using that as a dummy query to more quickly make an example. Your db query should be the same! You may need to use formatDataAsArray() if your db data isn't already formatted in that way.

ooh ok I got it, thank you very much for your help!

1 Like

Definitely post here if I can still help with anything :blush: