从下拉菜单中选择项目时,在页面上更新表单

时间:2015-03-04 17:11:11

标签: html asp-classic

我有以下代码;

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/betatrak_db.asp" -->
<%
Dim RS_Betatrak__MMColParam
RS_Betatrak__MMColParam = "1"
If (Request.Form("RL") <> "") Then 
  RS_Betatrak__MMColParam = Request.Form("RL")
End If
%>
<%
Dim RS_Betatrak
Dim RS_Betatrak_cmd
Dim RS_Betatrak_numRows

Set RS_Betatrak_cmd = Server.CreateObject ("ADODB.Command")
RS_Betatrak_cmd.ActiveConnection = MM_betatrak_db_STRING
RS_Betatrak_cmd.CommandText = "SELECT * FROM Betatrak_Length WHERE ID = ?" 
RS_Betatrak_cmd.Prepared = true
RS_Betatrak_cmd.Parameters.Append RS_Betatrak_cmd.CreateParameter("param1", 5, 1, -1, RS_Betatrak__MMColParam) ' adDouble

Set RS_Betatrak = RS_Betatrak_cmd.Execute
RS_Betatrak_numRows = 0
%>
<%
Dim RS_Run_Length
Dim RS_Run_Length_cmd
Dim RS_Run_Length_numRows

Set RS_Run_Length_cmd = Server.CreateObject ("ADODB.Command")
RS_Run_Length_cmd.ActiveConnection = MM_betatrak_db_STRING
RS_Run_Length_cmd.CommandText = "SELECT * FROM Run_Length" 
RS_Run_Length_cmd.Prepared = true

Set RS_Run_Length = RS_Run_Length_cmd.Execute
RS_Run_Length_numRows = 0
%>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <th width="45%" height="30" scope="col">Run Length</th>
    <th width="10%" scope="col">Qty</th>
    <th width="10%" scope="col">3.6M</th>
    <th width="10%" scope="col">2.4M</th>
    <th width="10%" scope="col">1.8M</th>
    <th width="10%" scope="col">1.2M</th>
  </tr>
  <tr><form name="form1" method="post" action="">
    <td><label>
      <select name="RL" id="RL">
        <option value="">- Please Select -</option>
        <%
While (NOT RS_Run_Length.EOF)
%>
<option value="<%=(RS_Run_Length.Fields.Item("ID").Value)%>"><%=(RS_Run_Length.Fields.Item("Run_Length").Value)%></option>
<%
  RS_Run_Length.MoveNext()
Wend
If (RS_Run_Length.CursorType > 0) Then
  RS_Run_Length.MoveFirst
Else
  RS_Run_Length.Requery
End If
%>
      </select>
    </label></td>
    <td><label>
      <input type="text" name="Qty" id="Qty">
    </label></td>
    <td><input name="B36" type="text" id="B36" value="<%=(RS_Betatrak.Fields.Item("B_36").Value)%>"></td>
    <td><input name="B24" type="text" id="B24" value="<%=(RS_Betatrak.Fields.Item("B_24").Value)%>"></td>
    <td><input name="B18" type="text" id="B18" value="<%=(RS_Betatrak.Fields.Item("B_18").Value)%>"></td>
    <td><label>
      <input name="B12" type="text" id="B12" value="<%=(RS_Betatrak.Fields.Item("B_12").Value)%>">
    </label></td></form>
  </tr>
</table>
</body>
</html>
<%
RS_Betatrak.Close()
Set RS_Betatrak = Nothing
%>
<%
RS_Run_Length.Close()
Set RS_Run_Length = Nothing
%>

我想要发生的是当选择“运行长度”时,表格将更新并显示所需的长度。

目前它不起作用,我认为是因为我试图在同一页面上这样做。

这可能吗?

1 个答案:

答案 0 :(得分:0)

您需要提交可以作为

完成的表单
<select name="RL" id="RL" onchange="this.form.submit()">

这样您就可以将现有代码与Request.Form(“RL”)

一起使用

<select name="RL" id="RL" onchange="window.location=mypage.asp?RL="+this.value;">

然后你可以使用Request.QueryString(“RL”)

获得价值