LeaVerou / awesomplete

Ultra lightweight, usable, beautiful autocomplete with zero dependencies.
http://leaverou.github.io/awesomplete/
MIT License
6.95k stars 609 forks source link

Input: Display label but submit value #17250

Closed mitchellknight closed 11 months ago

mitchellknight commented 11 months ago

Hey! I'm using Awesomplete on a search form. I need to display the Label in the user visible input field but send the value on submission. Right now the form submits the label which won't work.

Is this possible with Awesomplete?

My code looks something like this...

    let area = document.getElementById("area");
    new Awesomplete(area, {
        list: [
            {
                label: "New York",
                value: "6648"
            },
            {
                label: "California",
                value: "6649"
            }
        ],
        replace: function(suggestion) {
            this.input.value = suggestion.label;
        }
    });
mitchellknight commented 11 months ago

I found a duplicate issue with a solution: https://github.com/LeaVerou/awesomplete/issues/16893