...

View Full Version : multiple select box values



emehrkay
06-02-2006, 07:55 PM
i have a very simple multiple select box and a function to create an array of the selected items. that function doesnt work correctly though.



function confRes(){
var res = document.getElementById('restricted');
var len = res.length
var sel = new Array();

for(var i = 0; i < len; i++){
if(res[i].selected){
sel[i] = res[i].value;
}
}
}


if i select the third item in the list, when i alert the array it will be ,,3 and if its the third and seventh - ,,3,,,7 etc.

what am i doing wrong?
thanks

emehrkay
06-02-2006, 08:22 PM
i figured it out. i was using var i as the index. so if it would assign the index and create all of the missing ones.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum