Next/prev in html <select> list

  • Thread starter Knut-Frode Dagestad
  • Start date
K

Knut-Frode Dagestad

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
 
L

Lee

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.


--
 
K

Knut-Frode Dagestad

Lee said:
Knut-Frode Dagestad said:



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();
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top