exampe: 机器1具有型号2,3和4 机器2具有型号1,2和3 机器1,型号2有13个装置,机器2型号2有15个装置
我的代码: 的 main.asp
<!DOCTYPE html>
<html>
<head>
<link href="mystyle.css" rel="stylesheet" type="text/css"/>
<script src="javascript/jquery-1.11.3.min.js"></script>
</head>
<body>
<!--Inicialization, ...-->
<%
dim model, typee, palete
typee=""
model=""
palete=""
dim perguntas(20)
Set conn = Server.CreateObject("ADODB.Connection")
Set conn2 = Server.CreateObject("ADODB.Connection")
conn_string = "Provider=sqloledb;Server=INF0148\SQLEXPRESS;Database=#####;Uid=####;Pwd=###########"
conn.commandTimeout = 60
conn.Open conn_string
Set rs = Server.CreateObject("ADODB.Recordset")
Set rs2 = Server.CreateObject("ADODB.Recordset")
function options(value, data, select_id)
Response.Write ("<option value=""" & value & """")
if request.form(select_id) = value then
Response.Write ("selected")
end if
Response.Write(">" & data & "</option>")
end function
%>
<div id="main">
<!--choose type of machine-->
<form method="post">
<select name="maq" id="maq" onchange="this.form.submit()">
<option value="">Type of Machine:</option>
<%
conn.close
conn.Open conn_string
rs.Open "SELECT DISTINCT Type FROM models", conn
do until rs.EOF
for each x in rs.Fields
options x.value, x.value, "maq"
next
rs.MoveNext
loop
%>
</select>
</form>
<%typee=Request.Form("maq")%>
<!--Choose model-->
<form method="form">
<select name="model" id="model" onchange="this.form.submit()">
<option value="">Model:</option>
<%
conn.close
conn.Open conn_string
rs.Open "SELECT DISTINCT Model FROM models WHERE Type='"&typee&"'", conn
do until rs.EOF
for each x in rs.Fields
options x.value, x.value, "model"
next
rs.MoveNext
loop
model=Request.Form("model")
%>
</select>
</form>
<!--Number of Palets-->
<form method="post">
<%
conn.close
conn.Open conn_string
rs.Open "SELECT N_Palets FROM Models WHERE Type='"&typee&"' AND Model='"&model&"'", conn
dim temp
temp=0
do until rs.EOF
for each x in rs.Fields
if not IsNull(x.value) then
if temp=0 then
response.write("<select name=palets id=palets onchange=""this.form.submit()"";>")
response.write("<option value="">Number of Palets:</option>")
temp=1
end if
options x.value, x.value, "palets"
end if
next
rs.MoveNext
loop
paletes=Request.Form("palets")
%>
</form>
</div>
</body>
</html>
所以,当我选择类型......没关系时,页面显示正确的模型......当我选择模型时,页面重新加载并且我放松了所有内容。
你能帮助我吗?
答案 0 :(得分:0)
提交表单只提交该表单上的字段,而不提交其他表单上的任何其他字段。这就是为什么提交你的一个孩子表格会丢失一切。要修复它,请添加包含必要父数据的隐藏字段。
<!--Choose model-->
<form method="post">
<input type="hidden" name="maq" value="<%=Request.Form("maq")%>">
<select name="model" id="model" onchange="this.form.submit()">
[...]
</select>
</form>
对于palets形式,添加机器和&amp;模型为隐藏字段。