LeaVerou / awesomplete

Ultra lightweight, usable, beautiful autocomplete with zero dependencies.

Home Page:http://leaverou.github.io/awesomplete/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Input: Display label but submit value

mitchellknight opened this issue · comments

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;
		}
	});

I found a duplicate issue with a solution: #16893