您的位置:首页 > Web前端 > JavaScript

用javascript动态添加和删除文本框

2008-09-01 17:35 471 查看
用javascript动态添加和删除文本框

<script language="javascript">

function add()

{

option = new Array();

proportion = new Array();

str='<table>';

strstr=str+'<tr align=center valign=middle bgcolor=#FFFFFF>';

strstr=str+'<td width="100%" height="25"><input type="text" name=proportion></td>';

strstr=str+'<td width="100%" height="25"><input type="button" name=del onclick="this.parentNode.parentNode.parentNode.deleteRow(this.parentNode.parentNode.rowIndex)" value="删除"></td>';

strstr=str+'</tr></table>';

window.upid.innerHTML+=str+'';

}

</script>

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>

<body>

<form name="myform" onsubmit="javascript:return check()">

<table>

<tr>

<td>

<input name="Submit2" type="button" onclick="javascript:add()" value="增加">

</td>

</tr>

<tr>

<td>

<div id="upid"></div>

</td>

</tr>

</table>

</form>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: