Next/prev in html <select> list

Discussion in 'Javascript' started by Knut-Frode Dagestad, Aug 16, 2006.

  1. I have a <select> list in some html code with hundreds of options. Is it
    possible to use javascript to jump to the next/previous item in the list?

    Knut-Frode
     
    Knut-Frode Dagestad, Aug 16, 2006
    #1
    1. Advertising

  2. Knut-Frode Dagestad

    Lee Guest

    Knut-Frode Dagestad said:
    >
    >I have a <select> list in some html code with hundreds of options. Is it
    >possible to use javascript to jump to the next/previous item in the list?


    Yes.


    --
     
    Lee, Aug 16, 2006
    #2
    1. Advertising

  3. Lee wrote:
    > Knut-Frode Dagestad said:
    >
    >>I have a <select> list in some html code with hundreds of options. Is it
    >>possible to use javascript to jump to the next/previous item in the list?

    >
    >
    > Yes.
    >
    >


    'Yes' is correct answer!
    The solution is the following:

    <...in the html-code...>
    <input type="button" value="Up" onclick="shiftOps(selectname, -1)">
    <input type="button" value="Down" onclick="shiftOps(selectname, 1)">

    <...in the javascript-code....>
    function shiftOps(sEl, n) {
    sEl.selectedIndex = sEl.selectedIndex + n;
    sEl.focus();
    }
     
    Knut-Frode Dagestad, Aug 16, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stanley

    Calendar Prev/Next Month

    Stanley, Aug 29, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    402
    Tommy
    Aug 29, 2003
  2. =?Utf-8?B?UkY=?=

    Next/Prev Year in VS.Net Calendar Control

    =?Utf-8?B?UkY=?=, Jun 3, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    452
    =?Utf-8?B?UkY=?=
    Jun 3, 2004
  3. =?Utf-8?B?UkI=?=
    Replies:
    2
    Views:
    2,294
    =?Utf-8?B?UkI=?=
    Oct 14, 2004
  4. Darren
    Replies:
    3
    Views:
    534
    Darren
    Jun 22, 2005
  5. { CrossFire }

    Paging Prev-Next

    { CrossFire }, Jun 18, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    402
    { CrossFire }
    Jun 18, 2006
Loading...

Share This Page