我正在将以下组合框“选择页面”动态添加到 jsp 页面,该页面在更改时会填充另一个名为“对象”的组合框。选择页面下拉列表正在正确加载内容,但不会触发其上的事件。即填充对象。我一直在 populateObjects() 函数中保持警报,这表明它甚至没有调用此警报。请帮忙。
//Select Page
var cell4 = row.insertCell(3);
var element4 = document.createElement("select");
element4.setAttribute('id', 'selPageRow' + rowCount);
element4.setAttribute('name', 'selPageRow' + rowCount);
element4.setAttribute('onClick', 'javascript:populateObjects(this.options[this.selectedIndex].innerHTML,'+rowCount+');');
var PageArray = getPages();
var option = document.createElement("option");
option.text = "Select...";
option.value = "select";
element4.options.add(option);
for(var i=0;i<PageArray.length;i++)
{
var option = document.createElement("option");
option.text = PageArray[i].attributes[0].nodeValue;
option.value = PageArray[i].attributes[0].nodeValue;
element4.options.add(option);
}
cell4.appendChild(element4);
// Code for populating Object dropdown
function populateObjects(selectedValue,rowCount)
{
alert(selectedValue);
var SelBox = document.getElementById('selObjRow' + rowCount);
removeAllOptions(SelBox);
var ObjArry = getObjects(selectedValue);
var option = document.createElement("option");
option.text = "Select...";
option.value = "select";
SelBox.options.add(option);
if(ObjArry.length>0)
{
for(var i=0;i<ObjArry.length;i++)
{
var option = document.createElement("option");
option.text = ObjArry[i].attributes[0].nodeValue;
option.value = ObjArry[i].attributes[0].nodeValue;
SelBox.options.add(option);
}
}
else
{
var option = document.createElement("option");
option.text = "None";
option.value = "none";
SelBox.options.add(option);
}
cell5.appendChild(SelBox);
}