高手们请赐教页面提交后form2如何获取form1的值

xiaohongyd 2009-12-18 04:10:22
<html>
<form name="form1">
<input type='text' name="text1" value="hello,word">
</form>

<form name="form2" action="" method="post">
<input type="submit" name="Submit" value="提交">
</form>

<%
if request("submit")<>"" then
text=request("text1")
response.write text
end if
%>
</html>

请问这样提交能获取到form1的text的值吗?如果不行要怎样才能获取到呢?
...全文
78 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaohongyd 2009-12-18
  • 打赏
  • 举报
回复
<script language="javascript">
window.onload=function(){FuncName1()}

function FuncName1()
{
document.form2.text1.value = document.form1.text1.value;
}
</script>
<html>
<form name="form1">
<input type='text' name="text1" value="hello,word">
</form>

<form name="form2" action="a.asp" method="post">
<input type="hidden" name="text1">
<input type="submit" name="Submit" value="提交">
</form>

</html>


a.asp

<%=request("text1")%>



这个可以,谢谢了
xiaohongyd 2009-12-18
  • 打赏
  • 举报
回复
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function submitform(obj)
{
this.test.value = document.getElementById("text1").value;
return true;
}
</script>
</head>

<body><html>
<form name="form1">
<input type="text" name="text1" id="text1" value="hello,word">
</form>

<form name="form2" action="" method="post" onsubmit="return submitform(this)">
<input type="hidden" name="test" />
<input type="submit" name="Submit" value="提交">
</form>

<%
if request("submit") <>"" then
text1=request("test")
response.write (text1)
end if

%>

</body>
</html>


经过测试,还是无法获取form1的text1的值
sy_binbin 2009-12-18
  • 打赏
  • 举报
回复
<script language="javascript">
window.onload=function(){FuncName1()}

function FuncName1()
{
document.form2.text1.value = document.form1.text1.value;
}
</script>
<html>
<form name="form1">
<input type='text' name="text1" value="hello,word">
</form>

<form name="form2" action="a.asp" method="post">
<input type="hidden" name="text1">
<input type="submit" name="Submit" value="提交">
</form>

</html>



a.asp

<%=request("text1")%>
lovebaby 2009-12-18
  • 打赏
  • 举报
回复
<%
text=request("text1")
response.write text

%>
属于asp代码,所以你的form的action指向的一定要是一个.asp页面。

<html>
<form name="form1">
<input type='text' name="text1" value="hello,word">
</form>

<form name="form2" action="2.asp" method="post">
<input type="submit" name="Submit" value="提交">
</form>
</html>

[code=ASP]
<html>
<%
text=request("text1")
response.write text
%>
</html>
[/code]
xiaohongyd 2009-12-18
  • 打赏
  • 举报
回复
谢谢,再请问,如果form2是传递到另外一个页面,如2.html,在第二个页面可以获取到吗?

<html>
<form name="form1">
<input type='text' name="text1" value="hello,word">
</form>

<form name="form2" action="2.html" method="post">
<input type="submit" name="Submit" value="提交">
</form>
</html>



<html>
<%
text=request("text1")
response.write text

%>
</html>
lovebaby 2009-12-18
  • 打赏
  • 举报
回复

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function submitform(obj)
{
this.test.value = document.getElementById("text1").value;
return true;
}
</script>
</head>

<body><html>
<form name="form1">
<input type="text" name="text1" id="text1" value="hello,word">
</form>

<form name="form2" action="" method="post" onsubmit="return submitform(this)">
<input type="hidden" name="test" />
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>

28,406

社区成员

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

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