<!--
var count = 1;function addItem(){
count = count + 1;
var e=window.event.srcElement;   
   var tr1=e.parentElement.parentElement;  
   var tr2=mainTable.insertRow(); 
   tr2.className="biaodan-q";
  
   tr2.insertCell().innerHTML='&nbsp;<input type="button" value="删除" onclick="javascript:deleteItem();" title="'+count+'">';  
  
   tr2.insertCell().innerHTML='&nbsp;<input type="button" value="保存" onclick="javascript:getServerHtml();" title="'+count+'">';     tr2.insertCell().innerHTML='&nbsp;<input name="textfield" type="text" size="20">';      tr2.insertCell().innerHTML='&nbsp;<input name="textfield2" type="text" size="10">';   tr2.insertCell().innerHTML='&nbsp;<select name="select3" class="kuang"><option>――</option><option selected>任务B</option></select>';    tr2.insertCell().innerHTML="&nbsp;&nbsp;<input name='STARTDate"+count+"' type=text class=kuang  id='STARTDate"+count+"'  title='STARTDate"+count+"' value=2007-01-01 size=12>&nbsp;<a href='#' onClick='javascript:popUpCalendar(this, window.document.getElementById('STARTDate1'), 'yyyy-mm-dd');'><img src='../images/Date.gif' width='20' height='19' border='0' align='absmiddle'></a>";
 
   tr2.insertCell().innerHTML="&nbsp;&nbsp;<input name='ENDDate"+count+"' type=text class=kuang  id='ENDDate"+count+"' title='ENDDate"+count+"' value=2007-01-01 size=12>&nbsp;<img src='../images/Date.gif' width='20' height='19' border='0' align='absmiddle'></a>";     tr2.insertCell().innerHTML='&nbsp;&nbsp;<textarea name="textarea" cols="25" rows="2"></textarea>';  
}
JS报错,说语法错误.本人愚钝,没检查出来,功能是这样的,想动态的为表格添加一行进行数据录入.谢谢大家帮忙.........我测试得出报错的代码是(功能为选择起始日期,调用日历控件(JS)...):
tr2.insertCell().innerHTML="&nbsp;&nbsp;<input name='STARTDate"+count+"' type=text class=kuang  id='STARTDate"+count+"'  title='STARTDate"+count+"' value=2007-01-01 size=12>&nbsp;<a href='#' onClick='javascript:popUpCalendar(this, window.document.getElementById('STARTDate1'), 'yyyy-mm-dd');'><img src='../images/Date.gif' width='20' height='19' border='0' align='absmiddle'></a>";
 
   tr2.insertCell().innerHTML="&nbsp;&nbsp;<input name='ENDDate"+count+"' type=text class=kuang  id='ENDDate"+count+"' title='ENDDate"+count+"' value=2007-01-01 size=12>&nbsp;<img src='../images/Date.gif' width='20' height='19' border='0' align='absmiddle'></a>";  

解决方案 »

  1.   

    'javascript:popUpCalendar(this,   window.document.getElementById( 'STARTDate1 '),   'yyyy-mm-dd '); '>LZ前面是否有定義了 一個無素的name為 STARTDate1 ,還是你想就當前添加的行進行操 作啊。如果是 就改成
    'javascript:popUpCalendar(this,   window.document.getElementById( 'STARTDate1"+conut+" '),   'yyyy-mm-dd '); '>
      
      

  2.   

    谢谢,我已经那样改过了,还是报语法错误.是不是window.document.getElementById(   'STARTDate1 "+conut+ "   ')中的对象还没生成,不能够得到他的引用?还还所有其他原因.........
      

  3.   

    document.getElementById(       'STARTDate1   "+conut+   "       ')
    写法有错误
    document.getElementById("STARTDate1"+conut)
      

  4.   


    tr2.insertCell().innerHTML= "&nbsp;&nbsp; <input   name= 'STARTDate "+count+ " '   type=text   class=kuang     id= 'STARTDate "+count+ " '     title= 'STARTDate "+count+ " '   value=2007-01-01   size=12> &nbsp; <a   href= '# '   onClick= \"javascript:popUpCalendar(this,   window.document.getElementById( 'STARTDate1 '),   'yyyy-mm-dd '); \"> <img   src= '../images/Date.gif '   width= '20 '   height= '19 '   border= '0 '   align= 'absmiddle '> </a> ";里面引号用错了;\"javascript:popUpCalendar(this,   window.document.getElementById( 'STARTDate1 '),   'yyyy-mm-dd '); \"
      

  5.   

    谢谢familyX
    ............解决了