make certain values in select box greyed out and unselectable?

J

john

I'm looking to have a form where a drop down list contains my full range of
options even when some are not currently available. Is it possible to
produce a select box where some items could show differently (eg greyed out)
and not be selectable?

All suggestions welcome!!

Thanks

John
 
L

Lasse Reichstein Nielsen

john said:
I'm looking to have a form where a drop down list contains my full range of
options even when some are not currently available. Is it possible to
produce a select box where some items could show differently (eg greyed out)
and not be selectable?

<select>
<option>Yes</option>
<option disabled="disabled">No</option>
</select>

Since you are asking in a javascript group, I assume you need to
change the disabled state of an option dynamically:

formRef.elements['mySelect'].options[1].disabled=true;

/L
 
J

John

Thanks Lasse - I'd no idea this was a standard select box feature (Doh!),

John

Lasse Reichstein Nielsen said:
john said:
I'm looking to have a form where a drop down list contains my full range of
options even when some are not currently available. Is it possible to
produce a select box where some items could show differently (eg greyed out)
and not be selectable?

<select>
<option>Yes</option>
<option disabled="disabled">No</option>
</select>

Since you are asking in a javascript group, I assume you need to
change the disabled state of an option dynamically:

formRef.elements['mySelect'].options[1].disabled=true;

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top