tags:

views:

82

answers:

3

I appreciate that this may be a pretty daft question, but can anyone think of a way of having an initial value in a dropdown which isn't one of the options in the dropdown?

I'm looking for a snap-to-grid type thing where the options might be 10, 20, 30, 40... but the actual intial value might be say 17.543...

I want to show the intial value but force a sensible selection if the dropdown is changed.

+2  A: 

I guess one way to accomplish that would be to make the default option (Select.options[0]) default to the 17.543, and the options that you WANT to be available could be the subsequent options. Without a bit more information as far as how the initial value of 17.543.. is set, can't really help you beyond that. :)

Dustin Hansen
You've helped me enough to realise what I need to do is actually trivially simple, if I'd just thought about it the right way to begin with :)
fearofawhackplanet
No problem, glad I could give you a different perspective on it. :)
Dustin Hansen
A: 

you need to create a subclass for DropDownList.

check this : http://david.safitech.com/?p=53

ipat
A: 

From an HTML point of view I would suggest having an associated text box which populates the value initially set, and then change the value when the select list changes. That should be simple enough in javascript. You could also make the text box read-only to stop people putting other garbage values in it.

Jeepstone