<html>
<head>
<title>textbox</title>
<script type="text/javascript">
function addTextBox()
{
var n = document.getElementById("boxnum").value;
if (n>0) {
for (var i = 0;i<n;i++) {
document.body.insertAdjacentHTML('beforeEnd','<input type=text name=box'+i+' value="new added"><br> ');
}
}
}
</script>
</head>
<body>
<input type=text name="boxnum" id="boxnum">
<input type=button onclick="addTextBox()" value="ClickToAddTextbox"><br>
</body>
</html>
3 Jul 2012
Javascript动态增加输入框
根据指定的数字,点击按钮动态增加输入框的个数 下面是javascript函数跟测试页面代码
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment