0

So I have a datalist which contains a list of all the people available like this:

<datalist id="available">
     <option value="1">Name</option>
     <option value="2">Ginger</option>
</datalist>

The issue is when I have the input setup like this:

<input name="persontobechosen" type="text" list="available" placeholder="Bob">

It autocompletes by value, I need value to be sent to the server but the user to start typing what's inbetween the tags.

  • Have you tried changing the `value` attribute to `"Name"` and `"Ginger"`? – Oriol Feb 19 '15 at 18:17
  • That wouldn't do as I don't want "Name" and "Ginger" to be sent to the server I wan 1 and 2 to be sent to the server but for the user to type Name and Ginger – Ginger Geek Feb 19 '15 at 18:27
  • That can't be. The text displayed in a text `input` is its value, and its value is the data which will be submitted. Moreover, submitting "1" instead of "Name" would prevent you from knowing whether the user wrote "1" or "Name". – Oriol Feb 19 '15 at 18:38
  • The issue is I need to have a frontend to the id which is shown. There is a for loop within php which outputs each option tag. I need the server to get the ID of the person, not the name. – Ginger Geek Feb 19 '15 at 18:45
  • Yes, this is weird. I usually want the opposite too. Can't have it. Browsers should display both value and label though, so you can turn it around so it technically matches. – Rudie Mar 19 '15 at 20:44

0 Answers0