如何用登录同时把Form内容传给Login.asp?

zhangqihong 2000-06-12 12:48:00
我在编程中需要用超链接传递Form中Text中的值(username,password),不知如何实现?

用户名:<input class="inputext" type="text" name=username >
密  码:<input class="inputext" type="password" name=password><br><br>
<a href="checkuser.asp?loginaction=登录">登录</a>
...全文
645 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangqihong 2000-06-15
  • 打赏
  • 举报
回复
赵宏宇高手给了我巧妙解答35,ghj1976高手差一点5,在此谢谢.
代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
<script language="javascript">
function form1_onsubmit()
{
if (!isLength(document.form1.username.value)) return;
if (!isLength(document.form1.password.value)) return;
document.form1.submit() ;
}

function isLength(f)
{
if (f.length==0)
{
alert("不能为空");
return false;
}
else
{
return true;
}
}


function dl()
{
document.form1.loginaction.value="登录"
form1_onsubmit() ;
}
function sq()
{
document.form1.loginaction.value="申请"
form1_onsubmit() ;

}
</script>
</head>

<body bgcolor=beige style="font:9pt" topmargin=0 leftmargin=3>

<form name="form1" method="POST" action="checkuser.asp">
<table border=1 style="font:9pt" bordercolor=red>
<tr>
<td>
<input type="hidden" name="loginaction" size="20" >
用户名:<input class="inputext" type="text" name="username" size="10"><br>
密  码:<input class="inputext" type="password" name="password" size="10"><br>

<span style="cursor:hand;" onclick="javascript:dl()" > <img src="1.gif">登录</span>
<span style="cursor:hand;" onclick="javascript:sq()" ><img src="1.gif">申请</span>
</td>
</tr>
</table>
</form>
</body>
</html>


checkuser.asp:
Response.Write Request.Form("username")&"<br>"
Response.Write Request.Form("password")&"<br>"
Response.Write Request.Form("loginaction")&"<br>"

chinavip 2000-06-14
  • 打赏
  • 举报
回复
1.分别用
checkuser.asp?username=form.username&password=form.password&dowhat=申请
checkuser.asp?username=form.username&password=form.password&dowhat=登录

2.去掉form中的action
蝈蝈俊 2000-06-14
  • 打赏
  • 举报
回复
你的意思是用同时得到get、post 方式提交的东西,但两个提交方式是不可并用的。

zhangqihong 2000-06-14
  • 打赏
  • 举报
回复
大家好!
谢谢你们的解答,但仍然不能解决问题.可能我没有把问题说清楚.
我把源码改简单些,如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body bgcolor=beige style="font:9pt" topmargin=0 leftmargin=3>

<form name="loginform" method="POST" action="checkuser.asp">
<table border=1 style="font:9pt" bordercolor=red>
<tr>
<td>
用户名:<input class="inputext" type="text" name=username size="10"><br>
密  码:<input class="inputext" type="password" name=password size="10"><br>

<a href="checkuser.asp?loginaction=登录">登录</a>
<a href="checkuser.asp?loginaction=申请">申请</a>
</td>
</tr>
</table>
</form>
</body>
</html>
我的希望是我用户点了"登录"或"申请"后,能把username或password传递给checkuser.asp.
checkuser.asp源码如下:
<%
Response.Write Request.Form("username")&"<br>"
Response.Write Request.Form("password")&"<br>"
Response.Write Request.QueryString("loginaction")&"<br>"
%>

hcat1999 2000-06-14
  • 打赏
  • 举报
回复
我说过了在 form中加隐含的参数,
上面几位的方法也正确,如果你还说不行,那我只能手把手交你了
andyou2000 2000-06-13
  • 打赏
  • 举报
回复
form 中使用get方法,判断lg按钮的value可以了,何必高复杂。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
<style type="text/css">
<!--
A
{
text-transform:none;
text-decoration:none;
color:blue;
}
A:hover
{
color:red;
text-decoration:underline;
}
.inputext{
height:12pt;
font-size:9pt;
background-color:white;
border-color:green;
border-style:solid;
}


-->
</style>
</head>

<body bgcolor=beige style="font:9pt" topmargin=0 leftmargin=3>

<form name="loginform" method="GET" action="checkuser.asp">
<table border=1 style="font:9pt" bordercolor=red>
<tr>
<td>
用户名:<input class="inputext" type="text" name=username size="10"><br>
密  码:<input class="inputext" type="password" name=password size="10"><br>   

<input type="button" name="lg" onclick="return dl_onclick()" value="登录">
<input type="button" name="lg" onclick="return zc_onclick()" value="注册">
</td>
</tr>
</table>
</form>
</body>

checkuse.asp

<%
if request.querystring("lg")="登录" then
你的代码
else '申请
你的代码
end if
%>
hcat1999 2000-06-13
  • 打赏
  • 举报
回复
同意ghj1976的做法
其实zhangqihong只要在return dl、ZC_onclick()函数中加上document.loginform.submit()就可以了
蝈蝈俊 2000-06-13
  • 打赏
  • 举报
回复
<%@ Language=VBScript %>
<script language="javascript">
<!--
function apply()
{
if ((document.loginform.username.value!="")&&(document.loginform.password.value!="") )
{
document.loginform.loginaction.value ="申请";
document.loginform.submit();
}
else
{
alert("请输入用户名和密码");
}
}
function login()
{
if ((document.loginform.username.value!="")&&(document.loginform.password.value!="") )
{
document.loginform.loginaction.value ="登录";
document.loginform.submit();
}
else
{
alert("请输入用户名和密码");
}
}
-->
</script>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<form name="loginform" method="POST" action="checkuser.asp">
<table border=1 style="font:9pt" bordercolor=red>
<tr>
<td>
用户名:<input class="inputext" type="text" name=username size="10"><br>
密  码:<input class="inputext" type="password" name=password size="10"><br>   

<input type="hidden" name="loginaction" value="登录" >
<a href="javascript:login();">登录</a>
<a href="javascript:apply();">申请</a>
</td>
</tr>
</table>
</form>
<P> </P>

</BODY>
</HTML>
zhangqihong 2000-06-13
  • 打赏
  • 举报
回复
大家好!我的源码如下,大家写的都不能解决问题.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
<style type="text/css">
<!--
A
{
text-transform:none;
text-decoration:none;
color:blue;
}
A:hover
{
color:red;
text-decoration:underline;
}
.inputext{
height:12pt;
font-size:9pt;
background-color:white;
border-color:green;
border-style:solid;
}


-->
</style>
</head>

<body bgcolor=beige style="font:9pt" topmargin=0 leftmargin=3>

<form name="loginform" method="POST" action="checkuser.asp">
<table border=1 style="font:9pt" bordercolor=red>
<tr>
<td>
用户名:<input class="inputext" type="text" name=username size="10"><br>
密  码:<input class="inputext" type="password" name=password size="10"><br>   

<input type="button" name="lg" onclick="return dl_onclick()" value="登录">
<input type="button" name="lg" onclick="return zc_onclick()" value="注册">
<a href="checkuser.asp?loginaction=登录">登录</a>
<a href="checkuser.asp?loginaction=申请">申请</a>
</td>
</tr>
</table>
</form>
</body>
我的希望是我用户点了"登录"或"申请"后,能把username或password传递给checkuser.asp.
</html>

jl_zhy 2000-06-13
  • 打赏
  • 举报
回复
对不起,时间来不及,没太细看上面的发言
<span onclick="javascript:up()" >
<a href="javascript:login();">登录</a>
</span>
<javascript language="javascript">
function up()
{
表单名.submit();
}
</script>

yyb2000 2000-06-13
  • 打赏
  • 举报
回复
这个问题是获得查询字串的问题,在checkuser.asp中这样写
<%
if request.querystring("loginaction")="登录" then
你的代码
else '申请
你的代码
end if
%>
蝈蝈俊 2000-06-12
  • 打赏
  • 举报
回复
你那种方式应该是读不出值的。

给你一个替代的方法:
<form action="checkuser.asp" method="get" name="form1">
用户名:<input class="inputext" type="text" name=username >
密  码:<input class="inputext" type="password" name=password><br><br>

</form>
qxm 2000-06-12
  • 打赏
  • 举报
回复
这么个问题都讨论?
qxm 2000-06-12
  • 打赏
  • 举报
回复
那样不就泄密了吗?
hcat1999 2000-06-12
  • 打赏
  • 举报
回复
有错
因为form 没有action参数,而<a href="checkuser.asp?loginaction=登录">在gorm之外,所以你得不到username和password

<form action="http://expert.csdn.net/index.asp" method="post" >
<input class="input......
.....
<input type="submit" value=" 提交 " name="B1">
</form>

如果有不需要填写的参数,可以设一个<input type="hidden" name="loginaction" value="登录">

然后在接收的asp文件中用下面的语句接受参数就可以了
loginaction=request("loginaction")
……
davyguo 2000-06-12
  • 打赏
  • 举报
回复
我做过
<form name = go>
<input class="inputext" type="text" name=username >
密  码:<input class="inputext" type="password" name=password><br><br>
</form>
<a href="checkuser.asp?loginaction=登录">登录</a>在点中消息中调用go.submit
我就是这样做的


stellaxyq 2000-06-12
  • 打赏
  • 举报
回复
<form action="login.asp" method="post" name="form1">
用户名:<input class="inputext" type="text" name=username >
密  码:<input class="inputext" type="password" name=password><br><br>
<input type=submit name=submit id=submit1>

</form>

用FORM提交(POST方法比GET好,GET别人可以看见你输入的值)
在LOGIN。ASP中用
request.form("username")
request.form("password")
就可以读取值 了
蝈蝈俊 2000-06-12
  • 打赏
  • 举报
回复
代码贴上来。我给你改。
zhangqihong 2000-06-12
  • 打赏
  • 举报
回复
ren ran bu xing!!

28,390

社区成员

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

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