asp页面中用javascript插入单元格,onclick无效
我在asp页面有一个table(peixunqingkuang),有如下的javascript:
newRow=peixunqingkuang_table.insertRow(peixunqingkuang_table.rows.length);
newRow.ln=allCount_peixunqingkuang;
newRow.id=allCount_peixunqingkuang;
c3=newRow.insertCell(2);
c3.bgColor="#F1FCFA";
c3.align="CENTER";
c3.innerHTML="<input name=peixun_ksshijian type=text class=inp id=peixun_ksshijian size=10 onFocus=this.style.borderColor='#FF33CC' onMouseOver=this.style.borderColor='#33CC33' onMouseOut=this.style.borderColor='#84a1bd'
onClick=WdatePicker()/>";
c4=newRow.insertCell(3);
c4.bgColor="#F1FCFA";
c4.align="CENTER";
c4.innerHTML="<input name=peixun_jsshijian type=text class=inp id=peixun_jsshijian size=10 onFocus=this.style.borderColor='#FF33CC' onMouseOver=this.style.borderColor='#33CC33' onMouseOut=this.style.borderColor='#84a1bd'
onClick=WdatePicker()/>";
现在是插入一行的单元格中的onClick=WdatePicker()没有反应????谢谢
------解决方案--------------------属性值要用'或"括起来,你的内容里面包含',应该是这个解析出问题了
还有就是你的input id重复了
c3.innerHTML = "<input name=\"peixun_ksshijian\" type=\"text\" class=\"inp\"
id=\"peixun_ksshijian\" size=\"10\" onFocus=\"this.style.borderColor='#FF33CC'\" onMouseOver=\"this.style.borderColor='#33CC33'\" onMouseOut=\"this.style.borderColor='#84a1bd'\" onClick=\"WdatePicker()\"/>";
c4 = newRow.insertCell(3);
c4.bgColor = "#F1FCFA";
c4.align = "CENTER";
c4.innerHTML = "<input name=\"peixun_jsshijian\" type=\"text\" class=\"inp\"
id=\"peixun_jsshijian\" size=\"10\" onFocus=\"this.style.borderColor='#FF33CC'\" onMouseOver=\"this.style.borderColor='#33CC33'\" onMouseOut=\"this.style.borderColor='#84a1bd'\" onClick=\"WdatePicker()\"/>";