Multiple Selection Text Box

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
rrogulski
New User
Posts: 10
Joined: Fri Jan 20, 2012 2:29 pm
First Name: Rob
Last Name: Rogulski
Company Name: StoneRiver
Contact:

Multiple Selection Text Box

Post by rrogulski »

We are working with a multiple selection text box using javascript. Is there a way to retrieve all of the selected items? We have tried several of the value retrieval functions but they all return only the first selected value.
User avatar
Glenn
Profound Logic Staff Member
Posts: 124
Joined: Mon Apr 14, 2014 4:08 pm
First Name: Glenn
Last Name: Hopwood
Company Name: Profound Logic Software
State / Province: Ohio
Country: United States
Contact:

Re: Multiple Selection Text Box

Post by Glenn »

Rob,

Can I assume you are talking about a dropdown (officially known as a 'select box') widget?

If so, you could use some code like what's below to find out which items are selected. Note that the getObj() api shown requires the ID of the element you are working with.

Code: Select all

var i;
// For readablity
var mySelect = getObj("Dropdown1");

// Loop through the 'option' properties of the select box object and look
//  for those where the 'selected' property is true.
for (i=0 ; i < mySelect.options.length ; i++) {
  if (mySelect.options[i].selected) {
    // The 'value' property contains the entries from the 'choice values' property of the select box  
    // The 'innerHTML' property contains the entries from the 'choices' property of the select box 
    alert(mySelect.options[i].value + ' - ' + mySelect.options[i].innerHTML);
  }
}
Glenn
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests