5

How can I make the display and the value different for an html form datalist option?

For instance, for a select-option field, I can write: <option value="Fake">Sample</option> where "Sample" is displayed, but "Fake" is the value posted.

For a datalist, <option value="Sample" />, "Sample" is both displayed and used as the posted value.

How can I make it so I can post a different value from Sample in a datalist? Thanks!

I need this so I can dynamically populate the datalist from MySQL, displaying a name while using an ID, for example <option value="2">Bob</option> (if this were a select-option field instead of a database field).


I discovered that I could use <option value="Fake" label="Sample"/>, which will hide it in Firefox, but Opera still displays both the Value and the Label. Anyone have any further ideas to display Sample, but hide Fake?

The Codesee
  • 3,714
  • 5
  • 38
  • 78
user928984
  • 1,963
  • 2
  • 14
  • 13

1 Answers1

-2

Seems you can't with pure HTML without using some JS+CSS help.

Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278