无刷新增加表单行

效果如图:

代码如下:

<!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>

阅读更多

没有更多推荐了,返回首页