...

View Full Version : Settings for a form select list



NeoPuma
01-19-2006, 11:14 PM
I got a form, and it contains a select list:

<select name="Type">
<option value="Sub" disabled="True">I want a Sub Domain</option>
<option value="Own" disabled="True">I Own this domain</option>
<option value="Buy" disabled="True">I will buy it with this order</option>
<option value="Transfer" disabled="True">I would like to transfer this domain</option>
</select>
What I want to do is, using javascript (got the code all set out) set 'disabled' to False on selected ones. I have tried the following:

document.order.Type.Transfer.disabled = "False";
order is the name of my form - definatly
Type is the selects name - definatly
Transfer is the option's value, and then... how do I do it? I just get lost to be honest.

Any help appreciated, thanks!

glenngv
01-20-2006, 03:21 AM
disabled property in option tag is not supported in IE. It is supported in Firefox and probably in other compliant browsers. Just in case you're not bothering with IE, here's the code to re-enable option in Firefox:

document.order.Type.options[3].disabled = false; //"Transfer" option
Or if you give the option an id...

<option id="transferOption" value="Transfer" disabled="True">I would like to transfer this domain</option>
...
document.getElementById('transferOption').disabled = false;

NeoPuma
01-20-2006, 04:08 PM
I never know that didn't work in IE. Is there a way to disable it in IE?

Thanks

glenngv
01-23-2006, 03:43 AM
You can emulate a disabled looking option tag in IE by making the text as gray and when selected will revert back to the previous selection.

http://www.lattimore.id.au/2005/07/01/select-option-disabled-and-the-javascript-solution/

This is not perfect as you can still hover over "disabled" option but it's better than nothing.

I attempted my own solution by removing and replacing the option tag to be disabled with an <optgroup> tag which cannot be selected. I was able to "disable" it but I cannot "re-enable" it as it seems <optgroup> tag cannot be removed via DOM. I'll post the code when it's fully fixed. But there's still a limitation in IE in terms of the look. You can change the color but you cannot change the default style of bold and italic of an <optgroup> tag. The select tag in IE has very limited CSS and HTML support as it is an OS-replaced control.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum