点击按钮,生成表单

js:

  function addrow() {
    var table = document.getElementById("test_table");
    if (!table) return;
    var row=table.insertRow(table.rows.length-1);
 //添加
    var cell1=row.insertCell(0);
    var cell2=row.insertCell(1);
    var cell3=row.insertCell(2);
    cell1.innerHTML="";
    cell1.bgColor="#F9F9F9";
    cell2.innerHTML="<input id=/"license_add_name/" name=/"license_add_name/" maxlength=/"50/" size=/"20/" value=/"/"> <a href=/"#/"><img src=/"/icon_delete.gif/" alt=/"删除/" width=/"13/" height=/"13/"></a>";
    cell2.bgColor="#F9F9F9";
    cell3.innerHTML="图片: <input id=/"license_add_photo/" name=/"license_add_photo/" type=/"file/" style=/"padding:2px; width:200px;/">";
    cell3.bgColor="#F9F9F9";

  }

 

html:

<TABLE cid=test_table cellSpacing=1 cellPadding=0
      width="100%" border=0>
        <TBODY>
        <TR>
          <TD bgColor=#e7eef1>&nbsp;</TD>
          <TD bgColor=#e7eef1><STRONG>名称</STRONG></TD>
          <TD bgColor=#e7eef1><STRONG>照片</STRONG></TD></TR><!-- 新增 -->
        <TR>
          <TD bgColor=#fffde1>&nbsp;</TD>
          <TD bgColor=#fffde1>&nbsp;</TD>
          <TD align=right bgColor=#fffde1><IMG height=9 hspace=4
            src="/icon_add.gif" width=9><A
            href="javascript:addrow()">新增</A></TD></TR>

         </TBODY>

</TABLE>

你可能感兴趣的:(JavaScript,function,table,input,border,照片)