W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2008

[whatwg] [wf2] datalist value and label coupling to input

From: Ian Hickson <ian@hixie.ch>
Date: Sat, 1 Nov 2008 03:55:22 +0000 (UTC)
Message-ID: <Pine.LNX.4.62.0811010351390.1237@hixie.dreamhostps.com>
On Wed, 21 Nov 2007, Rikkert Koppes wrote:
>
> Suppose I have the following code snippet
>  
> <input name="pref" list="fruits">
> <datalist id="fruits">
> <option label="apple" value="1">
> <option label="pear" value="2">
> <option label="banana" value="3">
> </datalist>
> 
> Purpose is to enable the user to either type a new fruit name or select 
> an existing fruit number. Actually I want the list [apple,pear,banana] 
> as suggestion list, but as I understand correctly, the suggestion in 
> this case would be [1,2,3], the label elements are just annotations to 
> these values.
> 
> Is there any (proposed) solution to let the user work with the fruit 
> names, so names are given as suggestions and a different name might be 
> typed in, but submit the selected fruit number if one was picked from 
> the list?

No. The problem is that if we did that, you wouldn't be able to tell if 
the user had selected "apple" or typed "1" manually. If the user had typed 
a number, the server couldn't distinguish the number as the value intended 
by the user from a number as selected from a list.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Friday, 31 October 2008 20:55:22 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:06 UTC