View Full Version : multiple select box values

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++){
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?

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.