[whatwg] Form input element for value-unit pairs

Markus Ernst derernst at gmx.ch
Tue Mar 15 09:48:55 PDT 2011


Am 15.03.2011 17:36 schrieb Christoph Päper:
> Jukka K. Korpela:
>> Christoph Päper wrote:
>>
>>>   <input type="number" id="fontsize" value="12" unit="pt">
>>
>> Or do you mean that the presence of the unit="..." attribute would trigger a special implementation of numeric input, so that the user is expected to enter both a number and a unit, with the latter defaulted according to the unit attribute?
>
> Yes.
>
> UIs may autoconvert the value if the unit changes or keep it. I’m not sure which solution is better.
>
>> Although the need for number&  unit input is relatively common, I think it can quite satisfactorily be handled using a number input field and e.g. a dropdown menu of units accepted by an application (or maybe a textfield). After all, processing of the form data would most probably want to split a combined number&  unit data item into its components, so why put them together in the first place?
>
> Usability.
>
> Maybe it would work better with ‘datalist’:
>
>    <input name=fontsize type=number unit=typo>
>    <datalist id=typo>
>      <option value=2.835 label=pt>
>      <option value=1 label=mm>
>    </datalist>

I like this approach because it is author configurable and extensible 
beyond the rich text editor use case. A billing application might apply 
a list of currencies with appropriate exchange rates for the day.

What I do not yet understand is, in what point does this proposal 
enhance usability compared to a dropdown box with the units, and some 
client side script that does the conversion?



More information about the whatwg mailing list