急!高手帮一下忙,我动态的增加一行后,可是我怎样在form的提交页得到提交的变量 有两种方法:1.每列都使用同样的Name属性,如果有多列,在服务器端就接收信息就会是一个数组2.使用一个隐藏表单来储存新增加的字段名,到服务器端根据这个来读取数据。推荐使用第1种方法 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 to GageCSDN(稻草人) 1.每列都使用同样的Name属性,如果有多列,在服务器端就接收信息就会是一个数组 能不能说得再详细一些或者给实例。 新手上路,请多关照:) thx! response.write(request("name"))输出一下,你就知道什么是数组了 我这里写了一个例子,可供你参考一下,为了方便,我把HTML和ASP都写在一个文件里了。<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>表格编辑</title><style>td {font-size:12px;height:16px;}th {font-size:12px;height:18px;}a:hover { text-decoration: underline; font-size: 12px; color:red; }a { text-decoration: none; font-size: 12px; }span {font-size:12px;height:13px;}input {font-size:12px;height:13px;}</style><script language="JavaScript">var Focus_Obj = null;function addLine(){ myTbl.insertRow(); var tmpTR = myTbl.rows[myTbl.rows.length-1]; tmpTR.insertCell(); tmpTR.cells[0].innerHTML = "<input type=\"text\" name=\"FieldOne\" onchange=\"this.nextSibling.innerText=this.value;\" style=\"width:100%;border: 0 none;display:none;\"><span></span>"; tmpTR.cells[0].onclick = new Function("TD_Click(this);"); tmpTR.insertCell(); tmpTR.cells[1].innerHTML = "<input type=\"text\" name=\"FieldTwo\" onchange=\"this.nextSibling.innerText=this.value;\" style=\"width:100%;border: 0 none;display:none;\"><span></span>"; tmpTR.cells[1].onclick = new Function("TD_Click(this);"); tmpTR.insertCell(); tmpTR.cells[2].innerHTML = "<input type=\"text\" name=\"FieldThree\" onchange=\"this.nextSibling.innerText=this.value;\" style=\"width:100%;border: 0 none;display:none;\"><span></span>"; tmpTR.cells[2].onclick = new Function("TD_Click(this);"); tmpTR.insertCell(); tmpTR.cells[3].align = "center"; tmpTR.cells[3].innerHTML = "<a href=\"#\" onclick=\"delRow(this.parentElement.parentElement);\">删除</a>";}function delRow(row){ if(confirm("确认要删除这行吗?")) myTbl.deleteRow(row.rowIndex);}function TD_Click(obj){ if(Focus_Obj == obj) return false; if(Focus_Obj) { Focus_Obj.children[0].style.display = "none"; Focus_Obj.children[1].style.display = ""; } if(obj.tagName == "TD") { obj.children[0].style.display = ""; obj.children[1].style.display = "none"; obj.children[0].readonly = false; obj.children[0].select(); Focus_Obj = obj; }}</script></head><body><form action="" method="POST"><TABLE bgcolor="#6699FF" border="0" cellspacing="1" cellpadding="0" width="100%" id="myTbl"><TBODY bgColor="#FFFFFF"><TR bgColor="#99CCFF"> <TH>字段一</TH> <TH>字段二</TH> <TH>字段三</TH> <TH align="center">操作</TH></TR></TBODY></TABLE><table width="100%"><tr><td align="center"><input style="height:22px;" type="button" value="添加行" onclick="addLine();"> <input style="height:22px;" type="submit" name="UpLoad" value="提交数据"></td></tr></table></form></body><%If Request.Form("UpLoad") <> "" Then DataCount = Request.Form("FieldOne").count Response.Write "您提交了" & DataCount & "条记录,它们是:<br>" For i = 1 To DataCount FieldOne = Request.Form("FieldOne")(i) FieldTwo = Request.Form("FieldTwo")(i) FieldThree = Request.Form("FieldThree")(i) Response.Write i & ".[" & FieldOne & "] [" & FieldTwo & "] [" & FieldThree & "]<br>" NextEnd If%></html> 一个页面加载效果的想法,求实现。 一个页面如何使用多个"Prototype Carousel Class图片幻灯切换"特效 JS跨域求救 javascript select onchange... setTimeout的问题!急! 急!哪位大哥帮忙帮个函数!获取URL方面的问题! radio 简单问题。 求教一个问题,1分钟搞定! 我要如何才能在一个页面中刷新一个<select>的值?????????? 如何通过javascript修改注册表 菜单跨越框架显示 请教各位!!(在线等待)急!!
1.每列都使用同样的Name属性,如果有多列,在服务器端就接收信息就会是一个数组 能不能说得再详细一些或者给实例。
新手上路,请多关照:)
thx!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>表格编辑</title>
<style>
td {font-size:12px;height:16px;}
th {font-size:12px;height:18px;}
a:hover { text-decoration: underline; font-size: 12px; color:red; }
a { text-decoration: none; font-size: 12px; }
span {font-size:12px;height:13px;}
input {font-size:12px;height:13px;}
</style>
<script language="JavaScript">
var Focus_Obj = null;
function addLine()
{
myTbl.insertRow();
var tmpTR = myTbl.rows[myTbl.rows.length-1];
tmpTR.insertCell();
tmpTR.cells[0].innerHTML = "<input type=\"text\" name=\"FieldOne\" onchange=\"this.nextSibling.innerText=this.value;\" style=\"width:100%;border: 0 none;display:none;\"><span></span>";
tmpTR.cells[0].onclick = new Function("TD_Click(this);");
tmpTR.insertCell();
tmpTR.cells[1].innerHTML = "<input type=\"text\" name=\"FieldTwo\" onchange=\"this.nextSibling.innerText=this.value;\" style=\"width:100%;border: 0 none;display:none;\"><span></span>";
tmpTR.cells[1].onclick = new Function("TD_Click(this);");
tmpTR.insertCell();
tmpTR.cells[2].innerHTML = "<input type=\"text\" name=\"FieldThree\" onchange=\"this.nextSibling.innerText=this.value;\" style=\"width:100%;border: 0 none;display:none;\"><span></span>";
tmpTR.cells[2].onclick = new Function("TD_Click(this);");
tmpTR.insertCell();
tmpTR.cells[3].align = "center";
tmpTR.cells[3].innerHTML = "<a href=\"#\" onclick=\"delRow(this.parentElement.parentElement);\">删除</a>";
}function delRow(row)
{
if(confirm("确认要删除这行吗?"))
myTbl.deleteRow(row.rowIndex);
}function TD_Click(obj)
{
if(Focus_Obj == obj) return false;
if(Focus_Obj)
{
Focus_Obj.children[0].style.display = "none";
Focus_Obj.children[1].style.display = "";
}
if(obj.tagName == "TD")
{
obj.children[0].style.display = "";
obj.children[1].style.display = "none";
obj.children[0].readonly = false;
obj.children[0].select();
Focus_Obj = obj;
}}
</script>
</head><body>
<form action="" method="POST">
<TABLE bgcolor="#6699FF" border="0" cellspacing="1" cellpadding="0" width="100%" id="myTbl">
<TBODY bgColor="#FFFFFF">
<TR bgColor="#99CCFF">
<TH>字段一</TH>
<TH>字段二</TH>
<TH>字段三</TH>
<TH align="center">操作</TH>
</TR>
</TBODY>
</TABLE>
<table width="100%"><tr><td align="center"><input style="height:22px;" type="button" value="添加行" onclick="addLine();"> <input style="height:22px;" type="submit" name="UpLoad" value="提交数据"></td></tr></table>
</form>
</body>
<%
If Request.Form("UpLoad") <> "" Then
DataCount = Request.Form("FieldOne").count Response.Write "您提交了" & DataCount & "条记录,它们是:<br>" For i = 1 To DataCount
FieldOne = Request.Form("FieldOne")(i)
FieldTwo = Request.Form("FieldTwo")(i)
FieldThree = Request.Form("FieldThree")(i)
Response.Write i & ".[" & FieldOne & "] [" & FieldTwo & "] [" & FieldThree & "]<br>"
Next
End If
%>
</html>