xpages - populate combobox with values from column from two dimensional array -
i have 2 dimensional array. example :
viewscope.mytest = []; viewscope.mytest.push(["row1col1", "row1col2", "row1col3"]); viewscope.mytest.push(["row2col1", "row2col2", "row2col3"]);
etc
in combobox show values of column3. how can ?
to iterate through 3rd columns of array, need this:
// creating structure got var viewscope = { mytest: [] } viewscope.mytest.push(["row1col1", "row1col2", "row1col3"]); viewscope.mytest.push(["row2col1", "row2col2", "row2col3"]); viewscope.mytest.push(["row3col1", "row3col2", "row3col3"]); // combobox id var mycombobox = document.getelementbyid("mycombo"); // iterate through options of mytest (var in viewscope.mytest) { // create new option select var option = document.createelement("option"); // add 3rd columns text option.text = viewscope.mytest[i][2]; // add option select mycombobox.add(option); }
why?! - creating 2 dimensional array. works like: array[row][col] example. because indexes, start 0 , count length-1.
please take at: jsfiddle link
Comments
Post a Comment