innerHTML动态添加input,提交时无法获取其中的值
可以动态生成input.可是为什么取不到他的值?这个和innerHtml有关系吗<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KeChengEdit.aspx.cs" Inherits="Test.KeChengEdit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function add()
{
var ii = 0;
ii = getInput_zjCount();
// var newinput = document.createElement("input");
// newinput.nodeName = 'zj' + ii;
// updiv.appendChild(newinput);
var str = window.updiv.innerHTML;
var inputstr = '章节' + ii + ':<input type=text name=zj' + ii + ' /><br/> ';
window.updiv.innerHTML += inputstr;
// window.updiv.appendChild
// alert("共有" + ii + "个input");
}
function getInput_zjCount()
{
var inputCout = 0;
var i = 1;
var s = document.getElementsByName("zj" + i);
while (s.length != 0)
{
i++;
s = document.getElementsByName("zj" + i);
}
return i;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="hidden" name="editString" value="edit" />
<input type="hidden" name="ID" value="<%# IDValue%>" />
课程:<input type="text" id="input_kecheng" name="input_kecheng" runat="server" /><br />
学院:<input type="text" id="input_xueyuan" name="input_xueyuan" runat="server" /><br />
教师:<input type="text" id="input_teacher" name="input_teacher" runat="server" /><br />
专业:<input type="text" id="input_zhuanye" name="input_zhuanye" runat="server" /><br />
<div id="kechengInfo">
章节信息: <input type="button" value="添加章节信息" onclick="javascript:add()" /><br />
<div id="updiv">
<%# sb.ToString()%>
</div>
</div>
<br />
<input type="submit" value="编辑" />
</div>
</form>
</body>
</html>
input javascript --------------------编程问答-------------------- input 需要一个 ID
补充:.NET技术 , ASP.NET