Answer the question
In order to leave comments, you need to log in
How to pass a variable to the input as typed manually?
The problem is this.
There is a form to which the address autocomplete script is attached, in particular the zip code, city and street fields - if it matters, this is melissa, here's a demo .
Adapted to your requirements.
Three variables city, postcode and street - when you click on the selected element, the value is transferred to the input - an example.
document.querySelector("[name='city']").value = city;
document.querySelector("[name='postcode']").value = postcode;
Answer the question
In order to leave comments, you need to log in
[name='city']
There are no and
elements on the page [name='postcode']
. But on those that are, everything works
document.querySelector(".contactForm input").value = "123123123"
input.dispatchEvent(new Event("input"))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question