You can also simply track selected parameters with the onchange event in real time and collect them whenever you want. I admit that this is still a cycle, but at least you do not do it every time you need to get the selected parameters, and it has the added bonus of being simple (the time will come for the search, anyway ...). Working fiddle: http://jsfiddle.net/cyg9Z/
var Test; if (!Test) { Test = { }; } (function () { Test.trackSelected = function (e) { var selector = document.getElementById('selector'), selected = [], i = 0; for (i = 0; i < selector.children.length; i += 1) { if (selector.children[i].selected) { selected.push(selector.children[i].value) } } selector.selMap = selected; }; Test.addListeners = function () { var selector = document.getElementById('selector'), tester = document.getElementById('tester'); selector.onchange = Test.trackSelected; tester.onclick = Test.testSelected; }; Test.testSelected = function () { var div = document.createElement('div'); div.innerText = document.getElementById('selector').selMap.join(', '); document.body.appendChild(div); }; Test.addListeners(); }());โ
pete source share