473,385 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

SELECT drop down list - SKIP

I have an drop down list

let say:

<SELECT name="id" id="id" OnClick="Skip()">
<option value="0"></option>
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
<option value="4">Item 4</option>
</SELECT>


I have a skip button (with the OnClick javascript function, whenever I click
skip, the drop down list will select the next Item of the current one.

Example:
- the current selected item is Item 2, when click Skip, it will select Item
3
- the current selected item is Item 3, when click Skip, it will select Item
4
- the current selected item is Item 4, when click Skip, it will select the
first one, which is Value 0

like a circle...

how to do that in javascript ?
<Script language="javascript">

function skip()
{

}
</script>

thanks.

Mar 19 '07 #1
2 3202
On Mar 19, 12:54 pm, "magix" <m...@asia.comwrote:
I have an drop down list
I have a skip button (with the OnClick javascript function, whenever I click
skip, the drop down list will select the next Item of the current one.

great. what is the question ?

like a circle...
>
how to do that in javascript ?
if you already have the function then why you are asking.

html-
<SELECT id="idSel">
<option value="0">Item 0</option>
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
<option value="4">Item 4</option>
</SELECT><br>
<button onclick="Next()"Select Next </button>

JavaScript-
function Next(){
var SelEct=document.getElementById("idSel")
var Curr=SelEct.selectedIndex
SelEct.selectedIndex=(Curr<(SelEct.options.length-1))?++Curr:0
}

Mar 19 '07 #2
On Mar 20, 5:27 am, scripts.cont...@gmail.com wrote:
On Mar 19, 12:54 pm, "magix" <m...@asia.comwrote:
I have an drop down list
I have a skip button (with the OnClick javascript function, whenever I click
skip, the drop down list will select the next Item of the current one.
[...]
how to do that in javascript ?
[...]
>
JavaScript-
function Next(){
var SelEct=document.getElementById("idSel")
var Curr=SelEct.selectedIndex
SelEct.selectedIndex=(Curr<(SelEct.options.length-1))?++Curr:0

}
How about:

function nextOption(sel) {
var idx = sel.selectedIndex;
sel.selectedIndex = ++idx % sel.options.length;
}
--
Rob

Mar 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Diane Yocom | last post by:
Has anybody ever seen or written code for ASP that would mimic Access' multi-column combo box? Specifically, I have a drop down box that lists about 100 five-digit codes. Each of these codes has...
1
by: Rod Early | last post by:
I need to know when the select element's dropdown list is opened (as when the user clicks on the arrow or does ALT-downarrow from the keyboard). Similarly, I need to known when the dropdown list...
1
by: Julia Briggs | last post by:
Hello, is there anyway to insert an image on any particular <select> option line in a drop down list without using a specialty drop-down? Any good ones out there that can be made to resemble a...
3
by: Darren | last post by:
Please Help Me!! I've created a typical <form> and a <select> element. The options are created dynamically from my access database (using asp). There are about 70 options, and when you click...
4
by: Therese A. Sorna | last post by:
Hello all... I am using Access 2002, and am trying to find a way for a user to be able to select multiple entries from a drop-down list. I am hoping that given a list as such: a b c d
2
by: hypomite | last post by:
I have an handler for the SelectedIndexChanged event of a dropdown box. I have also set the AutoPostBack option to True. When you select any item besides the first one, the event sucessfully fires....
13
by: Oliver Hauger | last post by:
Hello, In my html form I show a select-element and if this element is clicked I fill it per JavaScript/DOM with option-elements. I use the following code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD...
2
by: crazychrisy54 | last post by:
Hi there I have a option, select drop down list which a user can open. My page however refreshes very frequently and when this occurs the selected drop down list will pop back up. The user then...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.