0

I've been trying to find how to fire a form submission when a completion is clicked with places autocomplete, but I cannot figure this out.

I have a custom method placeChanged which I'm calling with

this.autocomplete.addListener('place_changed', this.placeChanged)

and the method is as follows

placeChanged() {
    this.place = this.autocomplete.getPlace()
    const addressComponents = this.place.address_components

    if (addressComponents !== undefined) {
        const formattedAddress = this.formatAddressComponents(addressComponents)

        this.setAddressComponents(formattedAddress)
    }

    if (this.place.geometry !== undefined) {
        this.setGeometry(this.place.geometry)
    }
}

the form will submit upon clicking enter, but I would like it to submit whenever I choose a completion form the list so that I could get rid of the 'submit' button on my form. How can I achieve this? The docs doesn't cover this at all.

Darksi
  • 11
  • 2
  • 2
    Have you tried invoking 'submit' by getting form element, e.g. `document.getElementById("myForm").submit();` ? Please refer https://stackoverflow.com/questions/9855656/how-can-i-submit-a-form-using-javascript – manpreet Apr 18 '22 at 11:38

0 Answers0