a.asp中选择select的值,如何传到另一个页面list.asp?
a.asp中有个select:<selectname="select"><optionselected></option><optionvalue="11">11</op...
a.asp中有个select:
<select name= "select ">
<option selected> </option>
<option value= "11 "> 11 </option>
<option value= "12 "> 12 </option>
<option value= "13 "> 13 </option>
</select>
但是我想把select的值提交到另一个页面list.asp?,并通过选择的这个值查询数据库,
如用户反选12 ,则出现另一个页面list.asp?mc=12
怎么实现网址出现(list.asp?mc=12 )呢? 展开
<select name= "select ">
<option selected> </option>
<option value= "11 "> 11 </option>
<option value= "12 "> 12 </option>
<option value= "13 "> 13 </option>
</select>
但是我想把select的值提交到另一个页面list.asp?,并通过选择的这个值查询数据库,
如用户反选12 ,则出现另一个页面list.asp?mc=12
怎么实现网址出现(list.asp?mc=12 )呢? 展开
4个回答
展开全部
可以实现你的功能,可参考试用下:
a.asp
<form name="form1" method="post" action="" id="form1">
请选择<select name="mc">
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
</select>
<br />
<input name="submit" type="submit" value="提交" />
</form>
<%
mc=request.Form("mc")
submit=request.Form("submit")
if submit="提交" then
response.Redirect("list.asp?mc="&mc)
end if
%>
list.asp
<%
mc=request.QueryString("mc")
response.Write("您选择的是:"&mc)
%>
<br /><a href="a.asp">返回</a>
a.asp
<form name="form1" method="post" action="" id="form1">
请选择<select name="mc">
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
</select>
<br />
<input name="submit" type="submit" value="提交" />
</form>
<%
mc=request.Form("mc")
submit=request.Form("submit")
if submit="提交" then
response.Redirect("list.asp?mc="&mc)
end if
%>
list.asp
<%
mc=request.QueryString("mc")
response.Write("您选择的是:"&mc)
%>
<br /><a href="a.asp">返回</a>
展开全部
用post的方法不会在网址出现list.asp?mc=12,要使用get方法。代码如下:
<form name="form1" method="get" action="list.asp" id="form1">
请选择<select name="mc">
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
</select>
<br />
<input name="submit" type="submit" value="提交" />
</form>
另外,在list.asp要获取mc值应该这么写:
mc=request.querystring("mc")
<form name="form1" method="get" action="list.asp" id="form1">
请选择<select name="mc">
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
</select>
<br />
<input name="submit" type="submit" value="提交" />
</form>
另外,在list.asp要获取mc值应该这么写:
mc=request.querystring("mc")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
让这一个DropDownList控件启用强制回发!
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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 runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddSelect" runat="server" AutoPostBack="True">
<asp:ListItem>请选择</asp:ListItem>
<asp:ListItem>L1</asp:ListItem>
<asp:ListItem>L2</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnSubmit" runat="server" BackColor="Red" ForeColor="Black"
Text="提交" PostBackUrl="~/List.aspx" /></div>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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 runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddSelect" runat="server" AutoPostBack="True">
<asp:ListItem>请选择</asp:ListItem>
<asp:ListItem>L1</asp:ListItem>
<asp:ListItem>L2</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnSubmit" runat="server" BackColor="Red" ForeColor="Black"
Text="提交" PostBackUrl="~/List.aspx" /></div>
</form>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询