View previous topic
::
View next topic
|
Author |
Message |
ramon fincken Site's programmer
 Get a free globally recognized avatar It's free!
Joined: 03 Aug 2007 Posts: 412 Location: A'dam/Diemen, The Netherlands
|
Posted: Wed Aug 26, 2009 8:15 pm Post subject: [solution] Prototype Javascript: Select Multiple Dropdown Items (values) |
|
|
So I needed to have all values from:
Code: | 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> |
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:
http://ehsan.bdwebwork.com/2006/12/20/j...own-items/
Here's how to get 73+70+80 if 3 options are selected:
Code: |
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;
} |
|
|
Back to top |
|
 |
Google adsense Advertisement
|
Posted: Wed Aug 26, 2009 8:15 pm Post subject: [solution] Prototype Javascript: Select Multiple Dropdown Items (values) |
|
|
Advertisement
|
|
Back to top |
|
 |
GravityForms Advertisement
|
Posted: Wed Aug 26, 2009 8:15 pm Post subject: [solution] Prototype Javascript: Select Multiple Dropdown Items (values) |
|
|
Advertisement
 |
|
Back to top |
|
 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|