无刷新增加表单行

效果如图:

无刷新增加表单行_第1张图片

代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

 <HEAD>

  <TITLE> New Document </TITLE>

  <SCRIPT LANGUAGE="JavaScript">

  <!--

	function addattachfrom() {

		var newnode = document.getElementById('attachSrc').firstChild.cloneNode(true);

		document.getElementById('attachDest').appendChild(newnode);

	}

	function removeattachfrom() {

		var dest = document.getElementById('attachDest');

		dest.childNodes.length >= 1 && dest.lastChild ? dest.removeChild(dest.lastChild) : 0;

	}

  //-->

  </SCRIPT>

 </HEAD>



 <BODY>

 提示:点击[+]可以增加表单,点击[-]可以减少表单

  <table width="90%" align="center" cellpadding="0" cellspacing="0" class="celltable">

	  <tbody id="attachSrc">

		<tr><td width="100%">

			<table class="gray" border="0" cellspacing="2" cellpadding="2" style="border-left:1px solid #DEDEDE;border-right:1px solid #DEDEDE;border-top:1px solid #DEDEDE;border-bottom:1px solid #DEDEDE;">

				<tr>

					<td width="20%" align="right">名称</td>

					<td width="80%" align="left">

						<input type="text" name="GoodsName"/></td>

				</tr>

			</table>

		</td></tr>

	  </tbody>

	  <tbody id="attachDest"></tbody>

  </table><br />

  <a href="#add" onclick="addattachfrom();"> [+]</a>

  <a href="#remove" onclick="removeattachfrom();">[-]</a>

 </BODY>

</HTML>

你可能感兴趣的:(JavaScript,html,function,table,Class,border)