MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » 怎么在单元格里面动态添加文本框?

怎么在单元格里面动态添加文本框?

www.MyException.Cn  网友分享于:2013-01-10  浏览:51次
如何在单元格里面动态添加文本框? 求助
在表格里面动态添加文本框可以实现:
<input   name= "button "   type=button   onClick= 'additem( "tb ") '   value= "添加> > ">
  <table   id= "tb ">
  </table>
<script   language= "javascript ">
function   additem(id)
{
    var   row,cell,str;
    row   =   eval( "document.all[ "+ ' " '+id+ ' " '+ "] ").insertRow();
    if(row   !=   null   )
          {
                cell   =   row.insertCell();
                str= " <input   type= "+ ' " '+ "text "+ ' " '+ "   name= "+ ' " '+ "StuName "+ ' " '+ "> <input   type= "+ ' " '+ "button "+ ' " '+ "   value= "+ ' " '+ "删除 "+ ' " '+ "   onclick= 'deleteitem(this, "+ ' " '+ "tb "+ ' " '+ "); '> "
      cell.innerHTML=str;
            }
}
function   deleteitem(obj,id)
{
    var   rowNum,curRow;
    curRow   =   obj.parentNode.parentNode;
    rowNum   =   eval( "document.all. "+id).rows.length   -   1;
    eval( "document.all[ "+ ' " '+id+ ' " '+ "] ").deleteRow(curRow.rowIndex);
}
</script>

但是我要是想在表格的单元格里动态添加,应该怎么实现呢?


------解决方案--------------------
<td name= "inputWrapper "> </td>

<script language= "javascript ">
function addInput() {
document.getElementsByName( "inputWrapper ").innerHTML = " <input typpe= 'text '> ";
}
</script>

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有