opening a combo box from JS

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

    #1

    opening a combo box from JS

    Hi, I have a select box and I'd like to open it from JavaScript. Is
    this possible?
    I don't think it is but just in case one of you knew.
    I've tried combo.click(); ..focus() ..select()
    Graham
  • Gregor Kofler

    #2
    Re: opening a combo box from JS

    Laser Lips meinte:
    Hi, I have a select box and I'd like to open it from JavaScript. Is
    this possible?
    No.

    Gregor


    --
    http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
    http://web.gregorkofler.com ::: meine JS-Spielwiese
    http://www.image2d.com ::: Bildagentur für den alpinen Raum

    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: opening a combo box from JS

      Gregor Kofler wrote:
      Laser Lips meinte:
      >Hi, I have a select box and I'd like to open it from JavaScript. Is
      >this possible?
      >
      No.
      Before dismissing the idea entirely, I think it would be worthwhile to
      investigate if it was feasible to create an input event and dispatch it
      to the control, so that the control might show the desired behavior.


      PointedEars
      --
      Prototype.js was written by people who don't know javascript for people
      who don't know javascript. People who don't know javascript are not
      the best source of advice on designing systems that use javascript.
      -- Richard Cornford, cljs, <f806at$ail$1$8 300dec7@news.de mon.co.uk>

      Comment

      • SAM

        #4
        Re: opening a combo box from JS

        Gregor Kofler a écrit :
        Laser Lips meinte:
        >Hi, I have a select box and I'd like to open it from JavaScript. Is
        >this possible?
        >
        No.
        select box == <input type="select"?
        open == choice an item of the list (show an option) ?

        if yes :

        document.myForm .mySelect.selec tedIndex = 2;


        JS :
        ====

        function showOption(item ) {
        var s = document.myForm .mySelect, o = s.options;
        for(var i=0, n=o.length; i<n; i++)
        if(o[i].text == item) {
        s.selectedIndex = i;
        break;
        }
        }

        function launchOption(it em) {
        var s = document.myForm .mySelect, o = s.options;
        for(var i=0, n=o.length; i<n; i++)
        if(o[i].text == item) {
        location = o[i].value;
        break;
        }
        }

        HTML :
        ======

        <form name="myForm">
        <select name="mySelect" >
        <option value="http://www.google.com/">Google</option>
        <option value="http://www.yahoo.com/">Yahoo!</option>
        <option value="http://en.wikipedia.or g/">Wiki</option>
        </select>
        </form>
        <button onclick="showOp tion('Yahoo!')" >Show Yahoo!</button>
        <button onclick="launch Option('Wiki')" >Go to Wikipedia</button>

        --
        sm

        Comment

        • Gregor Kofler

          #5
          Re: opening a combo box from JS

          Thomas 'PointedEars' Lahn meinte:
          Gregor Kofler wrote:
          >Laser Lips meinte:
          >>Hi, I have a select box and I'd like to open it from JavaScript. Is
          >>this possible?
          >No.
          >
          Before dismissing the idea entirely, I think it would be worthwhile to
          investigate if it was feasible to create an input event and dispatch it
          to the control, so that the control might show the desired behavior.
          I doubt that - it would be a click event dispatched to the control, and
          then I think it is completely up to the browser's behaviour whether
          you'd get the according "visual feedback". Anyway, it won't be easy -
          most likely - and it won't work on "most browsers". I suppose it would
          be easier and more "cross browser" to fake a dropdown entirely with an
          ordinary input plus other block elements (like all those suggest widgets).

          Gregor

          --
          http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
          http://web.gregorkofler.com ::: meine JS-Spielwiese
          http://www.image2d.com ::: Bildagentur für den alpinen Raum

          Comment

          • Gregor Kofler

            #6
            Re: opening a combo box from JS

            SAM meinte:
            Gregor Kofler a écrit :
            >Laser Lips meinte:
            >>Hi, I have a select box and I'd like to open it from JavaScript. Is
            >>this possible?
            >>
            >No.
            >
            select box == <input type="select"?
            open == choice an item of the list (show an option) ?
            [code snipped]

            So what? That selects an option, but it won't "drop" the list of the
            dropdown. At least that's what I think the OP want's.

            Gregor


            --
            http://photo.gregorkof ler.at ::: Landschafts- und Reisefotografie
            http://web.gregorkofle r.com ::: meine JS-Spielwiese
            http://www.image2d.com ::: Bildagentur für den alpinen Raum

            Comment

            • Thomas 'PointedEars' Lahn

              #7
              Re: opening a combo box from JS

              Gregor Kofler wrote:
              SAM meinte:
              >Gregor Kofler a écrit :
              >>Laser Lips meinte:
              >>>Hi, I have a select box and I'd like to open it from JavaScript. Is
              >>>this possible?
              >>No.
              >select box == <input type="select"?
              >open == choice an item of the list (show an option) ?
              >
              [code snipped]
              >
              So what? That selects an option, [...]
              Does it? `select' is not a (Valid) value for the `type' attribute of the
              `input' element in the first place.


              PointedEars
              --
              Use any version of Microsoft Frontpage to create your site.
              (This won't prevent people from viewing your source, but no one
              will want to steal it.)
              -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

              Comment

              • Gregor Kofler

                #8
                Re: opening a combo box from JS

                Thomas 'PointedEars' Lahn meinte:
                Gregor Kofler wrote:
                >SAM meinte:
                >>select box == <input type="select"?
                >>open == choice an item of the list (show an option) ?
                >[code snipped]
                >>
                >So what? That selects an option, [...]
                >
                Does it? `select' is not a (Valid) value for the `type' attribute of the
                `input' element in the first place.
                I didn't understand those two lines and just skipped them. I was
                referring to the snipped code below. I should have snipped everything...

                Gregor


                --
                http://photo.gregorkof ler.at ::: Landschafts- und Reisefotografie
                http://web.gregorkofle r.com ::: meine JS-Spielwiese
                http://www.image2d.com ::: Bildagentur für den alpinen Raum

                Comment

                • SAM

                  #9
                  Re: opening a combo box from JS

                  Gregor Kofler a écrit :
                  SAM meinte:
                  >Gregor Kofler a écrit :
                  >>Laser Lips meinte:
                  >>>Hi, I have a select box and I'd like to open it from JavaScript. Is
                  >>>this possible?
                  >>>
                  >>No.
                  >>
                  >select box == <input type="select"?
                  >open == choice an item of the list (show an option) ?
                  >
                  [code snipped]
                  >
                  it won't "drop" the list of the dropdown.
                  Do not understand what that means (dropping)
                  (translation word to word in french has no meaning)
                  perhaps a picture of the feature ?

                  or do you mean something like :
                  Unwind, unfold(display) , show all the list ?

                  --
                  sm

                  Comment

                  • Gregor Kofler

                    #10
                    Re: opening a combo box from JS

                    SAM meinte:
                    or do you mean something like :
                    Unwind, unfold(display) , show all the list ?
                    Yes.

                    Gregor



                    --
                    http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
                    http://web.gregorkofler.com ::: meine JS-Spielwiese
                    http://www.image2d.com ::: Bildagentur für den alpinen Raum

                    Comment

                    • SAM

                      #11
                      Re: opening a combo box from JS

                      Gregor Kofler a écrit :
                      SAM meinte:
                      >
                      >or do you mean something like :
                      >Unwind, unfold(display) , show all the list ?
                      >
                      Yes.
                      OK.

                      function openDropdown() {
                      var s = document.myForm .mySelect;
                      s.size = o.length
                      }
                      function closeDropdown() {
                      var s = document.myForm .mySelect;
                      s.size = '';
                      }

                      :-)

                      --
                      sm

                      Comment

                      • Laser Lips

                        #12
                        Re: opening a combo box from JS

                        On Aug 24, 1:08 am, SAM <stephanemoriau x.NoAd...@wanad oo.fr.invalid>
                        wrote:
                        Gregor Kofler a écrit :
                        >
                        SAM meinte:
                        >
                        or do you mean something like :
                        Unwind, unfold(display) , show all the list ?
                        >
                        Yes.
                        >
                        OK.
                        >
                        function openDropdown() {
                        var s = document.myForm .mySelect;
                        s.size = o.length}
                        >
                        function closeDropdown() {
                        var s = document.myForm .mySelect;
                        s.size = '';
                        >
                        }
                        >
                        :-)
                        >
                        --
                        sm
                        That would not work because it would push everything below it down.

                        Don't think it it's possible.

                        Graham

                        Comment

                        • SAM

                          #13
                          Re: opening a combo box from JS

                          Laser Lips a écrit :
                          On Aug 24, 1:08 am, SAM <stephanemoriau x.NoAd...@wanad oo.fr.invalid>
                          wrote:
                          >>
                          >function openDropdown() {
                          >var s = document.myForm .mySelect;
                          >s.size = o.length}
                          >>
                          >function closeDropdown() {
                          >var s = document.myForm .mySelect;
                          >s.size = '';
                          >>
                          >}
                          >>
                          > :-)
                          >
                          That would not work because it would push everything below it down.
                          there was a smiley !
                          Don't think it it's possible.
                          certainly something as a tiptool could simulate the feature

                          here is using simple css :

                          <style type="text/css">
                          form p { position: relative; height: 1em }
                          form p select { position: absolute; z-index: 100 }
                          </style>

                          works (if it could say) in Firefox, Safari
                          not tested IE

                          <http://cjoint.com/data/iAmOH3aFc7_open _select.htm>

                          --
                          sm

                          Comment

                          Working...