How to make the display and value different for the datist parameter of the html form?

How to make the display and value different for the datist parameter of the html form?

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

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

How can I do this to post another value from Sample to datalist? Thank!

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


I found that I can use <option value="Fake" label="Sample"/>one that will hide it in Firefox, but Opera still displays the value of Value and Label. Does anyone have any other ideas to display Sample but hide Fake?

+5
source share
1 answer

It seems you cannot with pure HTML without using some JS + CSS help.

-2
source

All Articles