不要奸笑!asp有办法读到表格里的数据吗?100相送!

Jeroki 2002-08-19 04:27:30
<TR BGCOLOR="#FFFFFF">
<td width="75">将计就计</td>
<td width=246>文物外文</td>
<td width=38>810</td>
</tr>

如过能将上述三项数据一次性读进我的数据库,那该多爽啊!
...全文
118 24 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
sdtashenjie 2002-08-20
  • 打赏
  • 举报
回复
你可以设置隐含文本框,然后,些个函数,比如:
function ToSubmit() {
document.YourForm.HiddenElementNm1.value=YourId.rows(0).cells(0).innerText;
document.YourForm.HiddenElementNm2.value=YourId.rows(0).cells(1).innerText;
document.YourForm.HiddenElementNm3.value=YourId.rows(0).cells(2).innerText;
document.YourForm.submit();
}

Jeroki 2002-08-20
  • 打赏
  • 举报
回复
楼上的兄弟!为何不能运行呢!
hchxxzx 2002-08-20
  • 打赏
  • 举报
回复
<TABLE id=YourId>
<TR BGCOLOR="#FFFFFF">
<td width="75">001</td>
<td width=246>文物外文</td>
<td width=38>810</td>
</tr>
</TABLE>
<FORM ACTION="">

</FORM>
<script language="VBScript">
document.write "<form name='form1' METHOD=POST action='xxx.asp'><input type='hidden' name=hid1></form>"
for i=0 to document.all("yourid").rows(0).cells.length-1
str1=str1&YourId.rows(0).cells(i).innerText
next
document.all("hid1").value=str1
alert(document.all("hid1").value)
'赋值成功之后把它提交出去就可以写到数据库了
form1.submit()
</script>

caoshangfei 2002-08-20
  • 打赏
  • 举报
回复
up。。我也想要这样的程序,谁解决好了,麻烦也告诉我一下。。
Jeroki 2002-08-20
  • 打赏
  • 举报
回复
<TABLE id=YourId>
<TR BGCOLOR="#FFFFFF">
<td width="75">001</td>
<td width=246>文物外文</td>
<td width=38>810</td>
</tr>
</TABLE>

<script language="VBScript">
document.write YourId.rows(0).cells(0).innerText
document.write YourId.rows(0).cells(1).innerText
document.write YourId.rows(0).cells(2).innerText

</script>
輸出的結果如下:但我怎樣才能將其分別截取出來呢!因為我分別要寫入數据庫對應的字段中去
001文物外文810
yonghengdizhen 2002-08-20
  • 打赏
  • 举报
回复
你的提交方案有点不伦不类
Jeroki 2002-08-20
  • 打赏
  • 举报
回复
我這樣去做:
<script language="javavScript" type="text/VBScript">
function get_td(){
get_value=get_text.innerHTML;
window.location=window.location.href+"?return_get="+get_value;
}
</script>
<form name="form1" id="form1" method="post" action="haha.asp" onsubmit="get_td();return">
<td id=get_text>hahha</td>

<input type="submit" name="Submit" value="Submit" >
</form>
<br>
<%
=request.querystring("return_get")//為何其值輸不出來呢?
%>
Jeroki 2002-08-20
  • 打赏
  • 举报
回复
好!我就用樓上的主義測試一下!~
Jeroki 2002-08-20
  • 打赏
  • 举报
回复

:::::::::a.asp:::::::::::
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
dim s()
nameindex=Request.Form("nameindex")
nameindex=split(nameindex,"|")
redim s(ubound(nameindex))

for i=0 to ubound(nameindex)
s(i)= Request.Form(nameindex(i))
next
DbPath = SERVER.MapPath("kk.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DbPath
sql="insert into qq(test,test1,test2) values('" & s(0) & "','" & s(1) & "','" & s(2) & "')"////测试一行表格通过,先给分,但现在还有一个问题就是,在这里让其数值动态插入数据库,即表格有NN行,就一次性入库N行记录,此想法可行不?问题通过再给!

conn.Execute sql
conn.Close
set conn=nothing
%>
<TABLE border=1>
<tr><td><%=s(0)%></td><td><%=s(1)%></td><td><%=s(2)%></td></tr>
<tr><td><%=s(3)%></td><td><%=s(4)%></td><td><%=s(5)%></td></tr>
</TABLE>
</body>
</html>
Jeroki 2002-08-20
  • 打赏
  • 举报
回复
看来这个问题还是值得探讨!我去测试以下先。。。。。。。。。。
肄若芸 2002-08-20
  • 打赏
  • 举报
回复
<td id=get_text>hahha</td>
function get_td(){
get_value=get_text.innerHTML;
window.location=window.location.href+"?return_get="+get_value;
}

在你的asp中写入

get_in_asp_after_submit=request.querystring("return_get")
Go_Rush 2002-08-20
  • 打赏
  • 举报
回复
<!----a.htm--->

<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script>
function setform(){
var s="";
var nameindex="";
for (var i=0;i<table1.rows.length;i++)
for (var j=0;j<table1.rows(i).cells.length;j++){
s+="<input type=hidden name=\"m"+(i+1)+(j+1)+"\" value=\""+table1.rows(i).cells(j).innerText+"\">\n"
nameindex+="m"+(i+1)+(j+1)+"|"
}
nameindex=nameindex.substring(0,nameindex.length-1)
s+="\n<input type=hidden name=\"nameindex\" value=\""+nameindex+"\">\n"
s+="<input type=submit value=\"提交数据\">"
//alert(s);
form1.innerHTML=s;
}
</script>
</HEAD>
<body onload="setform()">
<TABLE id=table1 border=1>
<tr><td>001</td><td>002</td><td>003</td></tr>
<tr><td>一</td><td>二</td><td>三</td></tr>
</TABLE>
<form id=form1 action="a.asp" method=post>
</form>
</body>
</html>


<!---a.asp--->
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
dim s()
nameindex=Request.Form("nameindex")
nameindex=split(nameindex,"|")
redim s(ubound(nameindex))

for i=0 to ubound(nameindex)
s(i)= Request.Form(nameindex(i))
next

sql="insert into test values('" & s(0) & "')"

set conn=server.CreateObject("adodb.connection")
conn.Open "..{你的连接字符串}.."
conn.Execute sql
conn.Close
set conn=nothing
%>
<TABLE border=1>
<tr><td><%=s(0)%></td><td><%=s(1)%></td><td><%=s(2)%></td></tr>
<tr><td><%=s(3)%></td><td><%=s(4)%></td><td><%=s(5)%></td></tr>
</TABLE>
</body>
</html>
wanghui0380 2002-08-19
  • 打赏
  • 举报
回复
这个东东如果你不提交,永远不可能实现,要知道在web页面显示的表格都在前台显示的,也就说他是在你asp执行之后才显示的,你不提交怎么才能存入数据库??
我不知道,也许asp.net的run at server 可以
seventhmm 2002-08-19
  • 打赏
  • 举报
回复
用隐藏域可以实现!大家只能给你提示,具体你去查书吧!多调世几次就会了!
用别人的你永远不会!:)
flashasp 2002-08-19
  • 打赏
  • 举报
回复
各位可否詳細一點呢?
online 2002-08-19
  • 打赏
  • 举报
回复
试试xml
七伤拳 2002-08-19
  • 打赏
  • 举报
回复
用隐藏域,把表格中的文本读出来赋给此隐藏域,然后再ASP文件中读出来。
Go_Rush 2002-08-19
  • 打赏
  • 举报
回复
<TABLE id=YourId>
<TR BGCOLOR="#FFFFFF">
<td width="75">将计就计</td>
<td width=246>文物外文</td>
<td width=38>810</td>
</tr>
<TR BGCOLOR="#FFFFFF">
<td width="75">将计就计222222</td>
<td width=246>文物外文2222222</td>
<td width=38>81022</td>
</tr>

</TABLE>

<script>
alert(YourId.rows(0).cells(0).innerText);//显示第一行,第一列的数据
alert(YourId.rows(0).cells(1).innerText);//显示第一行,第二列的数据
alert(YourId.rows(0).cells(2).innerText);//显示第一行,第三列的数据
alert(YourId.rows(1).cells(0).innerText);//显示第二行,第一列的数据
</script>
yonghengdizhen 2002-08-19
  • 打赏
  • 举报
回复
用IE的数据绑定.

看MSDN去
MeXP 2002-08-19
  • 打赏
  • 举报
回复
用DOM好像可以做到
加载更多回复(4)

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧