Javascript 未调用下拉列表上的onclick事件
我将下面的组合框“选择页面”动态添加到jsp页面中,该页面会在更改后填充另一个名为“对象”的组合框。选择页面下拉列表正确加载内容,但不会触发其上的事件。i、 e.普及对象。我在populateObjects()函数中保持了警报,这表明它甚至没有调用此警报。请帮忙Javascript 未调用下拉列表上的onclick事件,javascript,dynamic,drop-down-menu,Javascript,Dynamic,Drop Down Menu,我将下面的组合框“选择页面”动态添加到jsp页面中,该页面会在更改后填充另一个名为“对象”的组合框。选择页面下拉列表正确加载内容,但不会触发其上的事件。i、 e.普及对象。我在populateObjects()函数中保持了警报,这表明它甚至没有调用此警报。请帮忙 //Select Page var cell4 = row.insertCell(3); var element4 = document.createElement("select"); ele
//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);
}
//选择页面
var cell4=行插入单元格(3);
var element4=document.createElement(“选择”);
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.text=“选择…”;
option.value=“选择”;
元素4.选项。添加(选项);
对于(var i=0;i0)
{
对于(var i=0;i将onClick
事件更改为onChange
事件
element4.setAttribute('onChange', 'javascript:populateObjects(this.options[this.selectedIndex].innerHTML,'+rowCount+');');
请提供一个与您的代码我很抱歉,但这是什么小提琴?哪里是行数
集?从我所看到的,你从来没有定义它。好的,让我更清楚地说明我的问题。这个代码在我朋友的系统上工作,用于在选择页面的更改上填充对象。而它不适用于我,尽管两者都有相同的IE版本。是否有IE设置中的任何调整使javascript工作?我将您的代码粘贴到a的javascript
部分,但我得到一个错误:“行未定义”。您能否制作一个包含可运行代码的小提琴,以便我们可以使用它并使其按您的要求工作?