So I needed to have all values from:
[code:1:8f00df4175] select multiple=”multiple” name=”cats” id=”cats” size=”5″>
option value=”73″>Catg Naam</option>
option value=”70″>CatNaam1</option>
option value=”90″>CatNaam2</option>
option value=”80″ >CatNaam3</option>
</select>[/code:1:8f00df4175]
how to do this? ( in order to make it usable for AJAX requests ).
A solution is to serialize them to XML but I needed a string.
Recoded from:
[url]http://ehsan.bdwebwork.com/2006/12/20/javascript-select-multiple-dropdown-items/[/url]
Here’s how to get 73+70+80 if 3 options are selected:
[code:1:8f00df4175]
alert(getmultiplevalues($(’cats’)));
/**
* Recoded by Ramon Fincken (www.ramonfincken.com) from: http://ehsan.bdwebwork.com/2006/12/20/javascript-select-multiple-dropdown-items/
*/
function getmultiplevalues(input)
{
var opt = input;
var numofoptions = opt.length;
var selValue = new Array;
var j = 0;
for (i=0; i<numofoptions; i++)
{
if (opt[i].selected === true)
{
selValue[j] = opt[i].value;
j++
}
}
selValue = selValue.join(“+”)
return selValue;
}[/code:1:8f00df4175]
Leave a Reply