Script to Open Select box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sammus
    New Member
    • Mar 2008
    • 4

    Script to Open Select box

    Hi,
    Ihave a requrement where I need to keep selec box in open state when a value in second box in "NO'


    Is there a way I can keep select box in open state?

    Thanks
  • mrhoo
    Contributor
    • Jun 2006
    • 428

    #2
    set the size attribute of the select element to expose that number of options-

    el.size=el.opti ons.length+'',
    or el.size=el.sele ctedIndex+'',
    or el.size='6'

    Comment

    • sammus
      New Member
      • Mar 2008
      • 4

      #3
      Thanks for the reply

      Its a dropdown list box/select box
      If I set el.size='6' , it will convert it to ListBox i want to keep it as dropdown select box, but only expanded or in open state

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Why would you want to do that?

        It's open when the user clicks on it. When it's in that state, the user is expected to select an option (which closes it again).

        Comment

        • sammus
          New Member
          • Mar 2008
          • 4

          #5
          its the feature requested by our client
          I have no idea how to call onclick event,
          is there a way to pass key values so that dropdown box can be in open state??
          Please help me

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            If it's a client request, tell them not everything is possible. The browser is the interface, so you're restricted by what the browser allows. I've not tried, but you may look into mutation events/fireEvent.

            Why not just give the focus to the select element instead? This will allow users to select options using the keyboard, though they won't be able to see all the options unless they click on it.

            Comment

            • sammus
              New Member
              • Mar 2008
              • 4

              #7
              Focus is for the dropdown/select box, they want that to be in an open state
              i tried calling onclick event in javascript, but its like calling the function to perform some operation, it won't open the dropdown list.

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                If it's not possible, it's not possible.

                Manually firing events doesn't always work, e.g. mouse and key events (if manually fired) don't always work as expected for security reasons.

                Comment

                Working...