By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,934 Members | 1,441 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,934 IT Pros & Developers. It's quick & easy.

Reading multiple selected items

Claus Mygind
100+
P: 571
I want to loop through an options array of a multiple select list and identify each selected item. All the examples I can find seem to deal with only reading the first selected item. A simple loop example would be appreciated.
Jan 12 '09 #1
Share this Question
Share on Google+
1 Reply


Claus Mygind
100+
P: 571
Well I figured it out
Expand|Select|Wrap|Line Numbers
  1.     var cNewVal = ""
  2.     for(i=0;i<document.getElementById("rDEPT").options.length;i++)
  3.     {
  4.         if (document.getElementById("rDEPT").options[i].selected )
  5.         {
  6.             cNewVal += document.getElementById("rDEPT").options[i].value+"~"
  7.         }
  8.     }
  9.  
  10.     document.getElementById("REVIEWDEPT").value = cNewVal
  11.  
Jan 12 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.