Click to See Complete Forum and Search --> : disabled input field?


webtekie
12-16-2003, 02:36 PM
Hi guys,

Is it possible to create a form input field where value cannot be altered and the box is grayed out (visible shows that box is uneditabled)?

thanks,
webtekie

fredmv
12-16-2003, 02:37 PM
<input type="text" value="foo" readonly="readonly" disabled="disabled" onfocus="blur();" />

webtekie
12-16-2003, 02:44 PM
thanks Fred!:D

fredmv
12-16-2003, 02:47 PM
No problem. ;)

webtekie
12-19-2003, 11:17 AM
One more thing,

I wanted to use the disable technique for <select>, it does job well but a little too well -- I can't scroll thru the list when it's disabled. Any suggestions?

thanks,
webtekie

fredmv
12-19-2003, 11:20 AM
Rather than disabling the <select> tag, disable the options that you don't want to be selected. For example:<select>
<option>&lt; select an option &gt;</option>
<option disabled="disabled">disabled</option>
<option>enabled</option>
</select>

webtekie
12-19-2003, 11:53 AM
Fred,

I tried your suggestion, but does not seem to work:


<select name="componentsList" multiple size="3"class="compLayer">
<option value="calendar" disabled="disabled">calendar</option>
<option value="clock" disabled="disabled">clock</option>
<option value="currency_field" disabled="disabled">currency_field</option>
<option value="decimal_field" disabled="disabled">decimal_field</option>
<option value="dollar_field" disabled="disabled">dollar_field</option>
<option value="percentage_field" disabled="disabled">percentage_field</option>
<option value="test_field" disabled="disabled">test_field</option>
</select>


I can still select list items.

thanks,
webtekie

fredmv
12-19-2003, 11:56 AM
Interestingly enough, that does work just fine in Mozilla 1.6a and Opera 7.23, yet fails in IE6. I guess you're going to have to find some alternate way of doing this if you need it to work in IE6 as well.

webtekie
12-19-2003, 12:01 PM
Strange, IE seems to take anything that is thrown its way...