Web Analytics Made Easy -
StatCounter deselect combolistbox item?? - CodingForum

Announcement

Collapse
No announcement yet.

deselect combolistbox item??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • deselect combolistbox item??

    Hi,
    I use a listbox with links as menu that opens a new link immediately after selecting an item. It works fine when it opens a new page. However, when going to a bookmark on the existing page, it will indeed jump to the bookmark, but the focus will remain on the listbox and subsequent scrolling results in scrolling in the listbox and opening of other links of items where it scrolls to. I know I can easily remove the focus from the listbox by clicking outside it, but is there a way to automatically loose focus after selection?
    Thanks for you help.

  • #2
    Create a new object using Option() method

    myopt = new Option();
    myopt.selectedIndex = 0;

    now whenever you want to bring the selectedIndex back to initial state


    object.selectedIndex = myopt;
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

    Comment


    • #3
      ex:

      PHP Code:
      <html>
      <
      head>
      <
      script>
      function 
      bla(a){
      myopt = new Option();
      myopt.selectedIndex 0;
      alert ('now i reset the options to the initial state');
      a.selectedIndex myopt;
      }
      </
      script>
      </
      head>

      <
      body>
      <
      select onchange="bla(this)">
      <
      option>choose</option>
      <
      option>1</option>
      <
      option>2</option>
      <
      option>3</option>
      </
      select>
      </
      body>
      </
      html
      KOR
      Offshore programming
      -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

      Comment


      • #4
        and, if you want to "defocus" the combo, interlace

        document.body.focus();
        a.selectedIndex = myopt;
        KOR
        Offshore programming
        -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

        Comment


        • #5
          Hi KOR,
          Thanks a lot,
          The document.body.focus() is all I wanted.
          Huub

          Comment

          Working...
          X