readOnly attribute doesn't work for drop down list?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt

    #1

    readOnly attribute doesn't work for drop down list?

    I want to know if readOnly attribute doesn't work for drop down list?
    If I try disabled attribute, it works fine for drop down list. When I
    try text box, it works fine for both disabled and readOnly attribute.

    For example, #1 will work, but #2 doesn't work

    1) <SELECT name="streetDir ection" class="FormInpu t" DISABLED>
    In JavaScript, I have InputForm.stree tDirection.disa bled = false;

    2) <SELECT name="streetDir ection" class="FormInpu t" readOnly>
    In JavaScript, I have InputForm.stree tDirection.read Only= false;

    any ideas? thanks!!
  • Mick White

    #2
    Re: readOnly attribute doesn't work for drop down list?

    Matt wrote:
    [color=blue]
    > I want to know if readOnly attribute doesn't work for drop down list?
    > If I try disabled attribute, it works fine for drop down list. When I
    > try text box, it works fine for both disabled and readOnly attribute.
    >
    > For example, #1 will work, but #2 doesn't work
    >
    > 1) <SELECT name="streetDir ection" class="FormInpu t" DISABLED>
    > In JavaScript, I have InputForm.stree tDirection.disa bled = false;
    >
    > 2) <SELECT name="streetDir ection" class="FormInpu t" readOnly>
    > In JavaScript, I have InputForm.stree tDirection.read Only= false;
    >
    > any ideas? thanks!![/color]
    "Select" is always read only.
    Mick

    Comment

    • Martin Honnen

      #3
      Re: readOnly attribute doesn't work for drop down list?



      Matt wrote:
      [color=blue]
      > I want to know if readOnly attribute doesn't work for drop down list?[/color]

      [color=blue]
      > 2) <SELECT name="streetDir ection" class="FormInpu t" readOnly>
      > In JavaScript, I have InputForm.stree tDirection.read Only= false;[/color]

      According to
      http://www.w3.org/TR/html4/interact/forms.html#h-17.6
      there is no readonly attribute defined for <select> elements thus there
      can't be a property for HTMLSelectEleme nt objects:
      http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-94282980

      --

      Martin Honnen
      http://JavaScript.FAQTs.com/

      Comment

      • Grant Wagner

        #4
        Re: readOnly attribute doesn't work for drop down list?

        Matt wrote:
        [color=blue]
        > I want to know if readOnly attribute doesn't work for drop down list?
        > If I try disabled attribute, it works fine for drop down list. When I
        > try text box, it works fine for both disabled and readOnly attribute.
        >
        > For example, #1 will work, but #2 doesn't work
        >
        > 1) <SELECT name="streetDir ection" class="FormInpu t" DISABLED>
        > In JavaScript, I have InputForm.stree tDirection.disa bled = false;
        >
        > 2) <SELECT name="streetDir ection" class="FormInpu t" readOnly>
        > In JavaScript, I have InputForm.stree tDirection.read Only= false;
        >
        > any ideas? thanks!![/color]

        The readonly attribute appears to not be supported on <select> elements
        by Firefox 0.9, IE6SP1 or Opera 7.51.

        <url:
        http://msdn.microsoft.com/workshop/a...cts/select.asp
        /> confirms this by not listing "readonly/readOnly" as a valid property
        on the <select> object.

        <url: http://www.w3.org/TR/html401/interac...html#h-17.12.2 /> also
        seems to confirm this behavior: "The following elements support the
        readonly attribute: INPUT and TEXTAREA."

        That spec doesn't specifically exclude SELECT, but it doesn't include it
        either, and the fact that none of the 3 user agents I tested support
        readonly on <select> points to user agents adhering to the letter of the
        spec.

        In other words, what you are seeing is documented behavior.

        Besides, what would be the point of a readonly <select>? It would appear
        to be a normal <select>, but it wouldn't open as a normal <select> does,
        which would be very confusing for the user.

        --
        | Grant Wagner <gwagner@agrico reunited.com>

        * Client-side Javascript and Netscape 4 DOM Reference available at:
        *


        * Internet Explorer DOM Reference available at:
        *
        http://msdn.microsoft.com/workshop/a...ence_entry.asp

        * Netscape 6/7 DOM Reference available at:
        * http://www.mozilla.org/docs/dom/domref/
        * Tips for upgrading JavaScript for Netscape 7 / Mozilla
        * http://www.mozilla.org/docs/web-deve...upgrade_2.html


        Comment

        Working...