R
rn5a
A Form has 2 select lists. The 1st one whose size is 5 (meaning 5
options are shown at any given time) allows multiple selection whereas
the 2nd one allows only 1 option to be selected at a time.
When an option is selected in the 2nd select list, the ASP page posts
itself. Assume that the 1st select list has the following 10 options
(note that both the select lists are actually populated from 2
different database tables):
Australia
Brazil
Canada
Denmark
Egypt
Finland
Ghana
Holland
India
Japan
Suppose a user has selected Brazil, Finland & Holland in the 1st
select list. Next the user selects an option in the 2nd select list.
This causes the ASP page to post. Now after posting the page, I want
the 1st select list to maintain its state so that Brazil, Finland &
Holland remain selected (since the user had selected these 3 options
in the 1st select list just before the page posted). This is how I
tried it but it selects only the last option among the 3 options (i.e.
after the page posts, only Holland remains selected):
===================================
<%
Dim arrLID,iEachLID,iLID,strLID,selFlag
strLID=Request.Form("location")
Dim objConn
Set objConn=Server.CreateObject("ADODB.CONNECTION")
'open the connection using ConnectionString
Dim strSQL
strSQL="SELECT * FROM Locations"
Dim objRS
Set objRS=Server.CreateObject("ADODB.RECORDSET")
objRS.Open strSQL,objConn
%>
<select name="location" multiple size=5>
<%
Do Until(objRS.EOF)
If Not(IsEmpty(strLID)) Then
arrLID=Split(strLID,", ")
For Each iEachLID In arrLID
iLID=iEachLID
If(CInt(iLID)=CInt(objRS("LID"))) Then
selFlag=" selected"
Else
selFlag=""
End If
Next
Else
selFlag=""
End If
%>
<option value="<%= objRS("LID") %>"<%= selFlag %>><%=
objRS("Location") %></option>
<%
objRS.MoveNext
Loop
%>
</select>
===================================
Can someone please point out what am I missing in the above code?
options are shown at any given time) allows multiple selection whereas
the 2nd one allows only 1 option to be selected at a time.
When an option is selected in the 2nd select list, the ASP page posts
itself. Assume that the 1st select list has the following 10 options
(note that both the select lists are actually populated from 2
different database tables):
Australia
Brazil
Canada
Denmark
Egypt
Finland
Ghana
Holland
India
Japan
Suppose a user has selected Brazil, Finland & Holland in the 1st
select list. Next the user selects an option in the 2nd select list.
This causes the ASP page to post. Now after posting the page, I want
the 1st select list to maintain its state so that Brazil, Finland &
Holland remain selected (since the user had selected these 3 options
in the 1st select list just before the page posted). This is how I
tried it but it selects only the last option among the 3 options (i.e.
after the page posts, only Holland remains selected):
===================================
<%
Dim arrLID,iEachLID,iLID,strLID,selFlag
strLID=Request.Form("location")
Dim objConn
Set objConn=Server.CreateObject("ADODB.CONNECTION")
'open the connection using ConnectionString
Dim strSQL
strSQL="SELECT * FROM Locations"
Dim objRS
Set objRS=Server.CreateObject("ADODB.RECORDSET")
objRS.Open strSQL,objConn
%>
<select name="location" multiple size=5>
<%
Do Until(objRS.EOF)
If Not(IsEmpty(strLID)) Then
arrLID=Split(strLID,", ")
For Each iEachLID In arrLID
iLID=iEachLID
If(CInt(iLID)=CInt(objRS("LID"))) Then
selFlag=" selected"
Else
selFlag=""
End If
Next
Else
selFlag=""
End If
%>
<option value="<%= objRS("LID") %>"<%= selFlag %>><%=
objRS("Location") %></option>
<%
objRS.MoveNext
Loop
%>
</select>
===================================
Can someone please point out what am I missing in the above code?