日期:2014-05-17  浏览次数:21084 次

ASP中request对象能获取button的 value值吗?
前段时间做的个小网站.测试代码如下:(以前时间是可以获取的,不知道为什么现在又获取不到了。分不多,请高手指点!)
<%
response.Write request("username")&"<br/>"
response.Write request("pwd")&"<br/>"
response.Write request("btn")
%>
<script>
function doSubmit()
{
document.form1.submit();
}
</script>
<html>
<head>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
</head>
<body id="body1">
<form action="button.asp" method="post" id="from1" name="form1">
<div><input type="text" name="username" /></div>
  <div><input type="password" name="pwd" /></div>
  <div><input type="button" name="btn" value="这是按钮" onClick="doSubmit()"/></div>
</form>
</body>
</html>


------解决方案--------------------
request肯定是不能获得button的值 ,你以前能获得那真神了,要么就是你改了程序代码
这个值可以通过js方式来获得,插入一个隐藏的input来实现
<%
For Each sForm in Request.Form
response.Write sForm &"=" &request.Form(sForm)&"<br/>"
Next
%>
<script>
function doSubmit()
{
document.form1.bbb.value= document.form1.btn.value;
document.form1.submit();
}
</script>
<html>
<head>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
</head>
<body id="body1">
<form action="1.asp" method="post" id="from1" name="form1">
<input type="hidden" name="bbb" />
<div><input type="text" name="username" /></div>
<div><input type="password" name="pwd" /></div>
<div><input type="button" name="btn" value="这是按钮" onClick="doSubmit()"/></div>
</form>
</body>
</html>