473,406 Members | 2,707 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,406 software developers and data experts.

How to get value(s) from Multiple Selection enabled Select Box

Hi All,

I'm on a task some thing like getting selected value(s) from source
SELECT box and appending these value(s) to destination SELECT box. Can
anyone help me how to get multiple values from SELECT box using
JavaScript (DOM).

Thanks in advance.

Jul 20 '05 #1
2 63015
Raghuram Banda <ra************@nokia.sify.net> writes:
I'm on a task some thing like getting selected value(s) from source
SELECT box and appending these value(s) to destination SELECT box. Can
anyone help me how to get multiple values from SELECT box using
JavaScript (DOM).


If the select element is "selRef", we can iterate through the selected
options as:

for (var i=selRef.options.length-1; i >= 0;i++) {
if (selRef.options[i].checked) {
// do something
}
}

I count backwards, so if you remove the option you are looking at,
it will not affect the ones you haven't visited yet.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Lasse Reichstein Nielsen <lr*@hotpop.com> writes:
for (var i=selRef.options.length-1; i >= 0;i++) { Doh, that should ofcourse be i--
if (selRef.options[i].checked) {


And this should be
if (selRef.options[i].selected) {
I hate it when I reflexively press submit before testing.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

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

Similar topics

3
by: Lori Costache | last post by:
Hi guys, I have a problem with multiple selection I have a list with 8 options in pull-down menu. For each option I have a price. Something like that :Element Price Table 10 Sofa ...
1
by: Polar | last post by:
I have a listbox with 5 options. I have set it up to be able to choise more than one option. What I need to know is how to get all the selection into the one string that is stored in the DB ...
1
by: Bung | last post by:
I am trying to retrieve selected values from a multiple select object on a page: *** Selection Page *** <form name="theForm"> <select name="numbers" MULITPLE> <option value="1">One</option>...
1
by: NiLaY | last post by:
I have a function like the one below to move a selected option from one listbox to another. But I want to be able to select multiple and be able to move those selections to the other listbox. Can...
3
by: kevcar40 | last post by:
Hi i have a form that allows the user to select criteria for searching on what i am trying to create now is a search for shifts i have three check boxes on the form ashift bshift cshift i...
10
by: ads | last post by:
hi, after binding the dropdownlist to a datasource, ive experience this error "Cannot have multiple items selected in a dropdownlist" after using the code:...
2
by: ggk517 | last post by:
I have a script like below: ------------------------------------------------------------------------------------------------------------------------ <html> <head> <title>TEST</title> <script...
0
jimleon
by: jimleon | last post by:
I have a post form for adding news articals to our website. It sends the headline and content and which category it belongs to to our MySQL database. This all works fine if a single category is...
10
by: mukeshrasm | last post by:
Hi I have a html in which there is two selection box and two radio button. Radio buttion is of array type. What I want if user will click the radio button then only he/she be able to make...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.