一个提交在HTML-ASP页面中进行查询和正常提交

时间:2011-02-24 23:09:27

标签: asp-classic

我希望在按下按钮时执行查询,然后按照填充其他结果进行操作。如果我只执行查询,一切正常,但我执行其他步骤,然后不执行查询。 我真的很感激任何帮助 以下是代码:

<form action="" method="POST">

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/TextDB.mdb"))

set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT Country FROM TheCountries ORDER BY Country"
rs.Open sql,conn

country=request.form("country")

%>

Select the Country <select name="country">
<%  do until rs.EOF
    response.write("<option")
    if rs.fields("country")=country then
      response.write(" selected")
    end if
    response.write(">")
    response.write(rs.fields("Country"))
    rs.MoveNext
loop
rs.Close
set rs=Nothing %>
</select>
<input type="submit" value="Show Countries">

<%
if country<>"" then
   sql="SELECT Country, City, Cost FROM TheCities WHERE country='" & country & "' Order by City" 
   set rs=Server.CreateObject("ADODB.Recordset")
   rs.Open sql,conn

city=request.form("city")
cost=request.form("cost")

%>
<br>

Select The City <select name="city">,
<%  do until rs.EOF
    response.write("<option")
    if rs.fields("city")=city then
      response.write(" selected")
    end if
    response.write(">")
    response.write(rs.fields("City") & "   " & rs.fields("Codigo"))
    rs.MoveNext
loop
rs.Close
conn.Close
set rs=Nothing
set conn=Nothing%>
</select>
<%  end if %>
</form>


<center>
<table border="0" cellpadding="0" cellspacing="0" width="80%"><tr><td>

<form action="_gdForm/webformmailer.asp" method="POST" target="_top" class="formmargin">
<input type="hidden" name="recipient" value="ramon_batista@hotmail.com">
<input type="hidden" name="subject"  value="WebSite Contact">
<input type="hidden" name="redirect" value="/thanksespanol.htm">
<input type="hidden" name="required" value="your_name,phone,country,city">
<input type="hidden" name="sort" value="your_name,phone,country,city">

<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr><td>

Name:<br>

</td></tr><tr><td>
<input type="text" name="your_name" size="40" class="shadeform"><br>
</td></tr><tr><td>


</td></tr><tr><td>

<script language="JavaScript" type="text/javascript" src="myscrip.js"></script>

<script language="JavaScript" type="text/javascript">

</script>

1 个答案:

答案 0 :(得分:0)

@ user633228:你有两个form。第一个查询不是第二个form的一部分,这就是为什么它不与它一起提交。你可能做的只是显示第一个表格,然后只用

显示第二个表格
If country <> "" Then
    ' Show other form
End If

将另一个<input type="hidden" name="country" value="<%=country %>">添加到第二个表单,以便country的值一起发送。