我有一个下拉菜单,但我无法获得所选项目的值。如果我使用request.form(“PageSelect”),则值为0,但我知道用于填充列表的多维数组有效。
<select name="PageSelect" onchange="this.form.submit()" style="font-weight:bold;">
<option value="">[All]</option>
<%
Dim PageArray
Dim PageCount
Set c = Server.CreateObject("ADODB.Connection")
Set r = Server.CreateObject("ADODB.Recordset")
r.CursorLocation = adUseServer
c.open connectionstring
c.CursorLocation = adUseServer
SQL = "select * from a_page order by P_Description"
Set r = Server.CreateObject("ADODB.Recordset")
r.CursorLocation = adUseServer
r.Open SQL, c, adOpenForwardOnly, adLockReadOnly
If r.BOF or r.EOF Then
r.close()
Set r = Nothing
Else
PageArray = r.GetRows()
PageCount = UBound(PageArray, 2)
r.Close()
Set r = Nothing
End If
c.Close()
Set c = Nothing
for i = 0 to PageCount
if PageSelect = pageArray(0,i) then
%>
<option selected value="<%=pageArray(0,i) %>"><%=pageArray(1,i) %></option>
<%
else
%>
<option value="<%=pageArray(0,i) %>"><%=pageArray(1,i) %></option>
<%
end if
next %>
</select>
以上代码是另外2个不同项目的选择框
<select id="PermissionID" name="PermissionID" onChange="this.form.submit()" style="font-weight:bold;">
<option value="0">[All Permissions]</option>
<% obj_ADO.ClearParameters
lng_RecSet1 = obj_ADO.GetFreeRecordset
obj_ADO.Recordset "A_combo_Permissions_select", adCmdStoredProc, obj_Session.int_CommandTimeout, lng_RecSet1
while obj_ADO.EOF(lng_RecSet1) = 0
if obj_ADO.GetField(0, adValue, lng_RecSet1) = lng_PermissionID then
%>
<option selected value="<%=obj_ADO.GetField(0, adValue, lng_RecSet1)%>"><%=obj_ADO.GetField(1, adValue, lng_RecSet1)%></option>
<%
else
%>
<option value="<%=obj_ADO.GetField(0, adValue, lng_RecSet1)%>"><%=obj_ADO.GetField(1, adValue, lng_RecSet1)%></option>
<%
end if
obj_ADO.MoveNext lng_RecSet1
wend
obj_ADO.CloseRecordset lng_RecSet1
%>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<select multiple size="10" name="ActionPermissionID" id="ActionPermissionID">
<option value="">[Add/Remove Permission]</option>
<% obj_ADO.ClearParameters
lng_RecSet1 = obj_ADO.GetFreeRecordset
obj_ADO.Recordset "A_combo_Permissions_select", adCmdStoredProc, obj_Session.int_CommandTimeout, lng_RecSet1
while obj_ADO.EOF(lng_RecSet1) = 0
if not isarray(lng_ActionPermissionID) then
if obj_ADO.GetField(0, adValue, lng_RecSet1) = lng_ActionPermissionID then
%>
<option selected value="<%=obj_ADO.GetField(0, adValue, lng_RecSet1)%>"><%=obj_ADO.GetField(1, adValue, lng_RecSet1)%></option>
<%
else
%>
<option value="<%=obj_ADO.GetField(0, adValue, lng_RecSet1)%>"><%=obj_ADO.GetField(1, adValue, lng_RecSet1)%></option>
<%
end if
else
%>
<option value="<%=obj_ADO.GetField(0, adValue, lng_RecSet1)%>"><%=obj_ADO.GetField(1, adValue, lng_RecSet1)%></option>
<%
end if
obj_ADO.MoveNext lng_RecSet1
wend
obj_ADO.CloseRecordset lng_RecSet1
%>
</select>
答案 0 :(得分:0)
这是问题 -
if len(Request.Form("PageSelect"))>0 and isnumeric(Request.Form("PageSelect")) then
PageSelect = clng(Request.Form("PermissionID"))
else
PageSelect = 0
end if
改为此 -
if len(Request.Form("PageSelect"))>0 and isnumeric(Request.Form("PageSelect")) then
PageSelect = clng(Request.Form("PageSelect"))
else
PageSelect = 0
end if