LeaVerou / awesomplete

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

Input: Display label but submit value #17250

Closed mitchellknight closed 1 year ago

mitchellknight commented 1 year 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 1 year ago

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