Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Oct 2004
    Posts
    104
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Settings for a form select list

    I got a form, and it contains a select list:
    Code:
    <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:
    Code:
    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!

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,964
    Thanks
    0
    Thanked 236 Times in 233 Posts
    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:
    Code:
    document.order.Type.options[3].disabled = false; //"Transfer" option
    Or if you give the option an id...
    Code:
    <option id="transferOption" value="Transfer" disabled="True">I would like to transfer this domain</option>
    ...
    document.getElementById('transferOption').disabled = false;

  • #3
    Regular Coder
    Join Date
    Oct 2004
    Posts
    104
    Thanks
    7
    Thanked 2 Times in 2 Posts
    I never know that didn't work in IE. Is there a way to disable it in IE?

    Thanks

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,964
    Thanks
    0
    Thanked 236 Times in 233 Posts
    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/0...ript-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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •