disable multiple select box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shanmugamit
    New Member
    • Feb 2008
    • 45

    disable multiple select box

    hi,

    i want disable the select box...
    Code:
    <script>
    document.frmreq.selintloc.disabled=true;
    </script>
    
    
    <select name=selitloc[] mutiple=mutiple>
    <option value=chennai>chennai</option>
    <option value=salem>salem</option>
    </select>
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Look at this example
    Last edited by hsriat; Feb 25 '08, 12:24 PM. Reason: Link added

    Comment

    • vee10
      New Member
      • Oct 2006
      • 141

      #3
      Hi,

      I think document.form cannot identify the name it can identify the id's only
      if u change the name to id then it works fine

      instead of <select name=selitloc[] mutiple=mutiple >

      use <select id=selitloc[] mutiple=mutiple >



      Originally posted by shanmugamit
      hi,

      i want disable the select box...
      Code:
      <script>
      document.frmreq.selintloc.disabled=true;
      </script>
      
      
      <select name=selitloc[] mutiple=mutiple>
      <option value=chennai>chennai</option>
      <option value=salem>salem</option>
      </select>

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by shanmugamit
        hi,

        i want disable the select box...
        Code:
        <script>
        document.frmreq.selintloc.disabled=true;
        </script>
        document.frmreq .elements["selintloc[]"].disabled=true;

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Originally posted by vee10
          Hi,

          I think document.form cannot identify the name it can identify the id's only
          if u change the name to id then it works fine

          instead of <select name=selitloc[] mutiple=mutiple >

          use <select id=selitloc[] mutiple=mutiple >
          No, you can identify an element by its name. Anyway, what you're suggesting would be incorrect. It might work in IE, but it's wrong. I don't think an id can have square brackets. If you did give an element an id, the correct way to refer to it would be with document.getEle mentById.

          Comment

          • vee10
            New Member
            • Oct 2006
            • 141

            #6
            ok i am not sure abt that thats why i told i think so
            anyway thanks for clarifying my doubt but why it is giving null or not an object if we are using name and invoking it.can u clarify that also


            Originally posted by acoder
            No, you can identify an element by its name. Anyway, what you're suggesting would be incorrect. It might work in IE, but it's wrong. I don't think an id can have square brackets. If you did give an element an id, the correct way to refer to it would be with document.getEle mentById.

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Originally posted by vee10
              ok i am not sure abt that thats why i told i think so
              anyway thanks for clarifying my doubt but why it is giving null or not an object if we are using name and invoking it.can u clarify that also
              Because the element is called "selintloc[]" (with the brackets). See post #4.

              Comment

              Working...