1
votes

How can I collect via CSJS the selected value(s) in a xp:listbox control?

I tried the samples similar for checkboxes / radiobuttons/ input field but this does not give me the correct values in return.

http://celinainsurance.blogspot.se/2011/04/getting-setting-values-with-ssjs-and.html

2

2 Answers

1
votes

This is more a JavaScript question then an XPages one, so if you search Google/ SO for 'javascript get selected options select' you'll find plenty of examples for your question.

That said, here's an example of the code you can use to get the selected options:

var selected = [];
var lb = document.getElementById("#{id:yourListBoxId}");

for (var i=0; i<lb.options.length; i++) {
  var o = lb.options[i];
  if (o.selected) { selected.push(o.value); }
}

console.log(selected); 
1
votes

I am using the jQuery val() function