如何設置爲我生成的列表框jsf的單個元素?我想通過JS來設置它。通過JavaScript設置列表框的元素
HTML generated: <select id="pageForm:effectiveDateListbox" name="pageForm:effectiveDateListbox" multiple="multiple" size="0"></select>
var listBox = document.getElementById('pageForm:effectiveDateListbox');
for (i = 0; i!= length; i++)
{
var date = arrDates[i];
var displayMonth = date.getMonth() + 1;
var displayYear = date.getFullYear();
var displayDate = date.getDate();
tokenizedDates = displayMonth.toString(10) + "/" + displayDate.toString(10) + "/" + displayYear.toString(10);
listBox.options[i].value = tokenizedDates;
i++;
}
你不需要'我'++在你的循環的循環結束本身將增加它。 – 2013-04-21 00:36:56