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
%>
===================================
Can someone please point out what am I missing in the above code?
Re: Multiple Select List
am 27.04.2007 04:18:39 von reb01501
rn5a@rediffmail.com wrote:
> 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"
http://www.aspfaq.com/show.asp?id=2096
>
> Dim objRS
> Set objRS=Server.CreateObject("ADODB.RECORDSET")
> objRS.Open strSQL,objConn
> %>
>
Re: Multiple Select List
am 27.04.2007 04:40:34 von rn5a
On Apr 26, 7:18 pm, "Bob Barrows [MVP]"
wrote:
> r...@rediffmail.com wrote:
> > 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"
>
> http://www.aspfaq.com/show.asp?id=2096
>
>
>
>
>
>
>
> > Dim objRS
> > Set objRS=Server.CreateObject("ADODB.RECORDSET")
> > objRS.Open strSQL,objConn
> > %>
> >
Re: Multiple Select List
am 27.04.2007 05:30:18 von rn5a
On Apr 26, 7:40 pm, r...@rediffmail.com wrote:
> On Apr 26, 7:18 pm, "Bob Barrows [MVP]"
> wrote:
>
>
>
>
>
> > r...@rediffmail.com wrote:
> > > 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"
>
> >http://www.aspfaq.com/show.asp?id=2096
>
> > > Dim objRS
> > > Set objRS=Server.CreateObject("ADODB.RECORDSET")
> > > objRS.Open strSQL,objConn
> > > %>
> > >
Re: Multiple Select List
am 27.04.2007 12:55:46 von reb01501
rn5a@rediffmail.com wrote:
> Bob, I encountered a new problem with the 1st select list.
>
> Suppose Brazil, Finland & Holland are selected in the 1st select list.
> Next I select an option from the 2nd select list; the page posts & the
> 1st select list shows Brazil, Finland & Holland selected.
>
> After this, I again select a different option in the 2nd select list;
> again the page gets posted but surprisingly, the options selected in
> the 1st select list i.e. Brazil, Finland & Holland no longer remain
> selected. In fact, when I click the submit button, the action page
> just retrieves an empty string i.e. Request.Form("location") is just
> an empty string instead of the location ids (objRS("LID")) of the 3
> locations!
>
> Why is the 1st select list losing its state under such circumstances?
>
> Please note that when an option is selected in the 2nd selected list,
> the page posts to itself (which I have done using JavaScript) but when
> the submit button is clicked, the page posts to another page.
It's got to have something to do with the way the form is getting submitted.
Help us out by posting a small repro. Create a new pair of test pages that
contain nothing but the code needed to reproduce this problem and post them
here. We need to run your code in order to test it, and we do not have your
database, so hardcode the option list in the second select element and
substitute an ad hoc recordset for the recordset actually used in your
actual code to populate the first select element:
Dim objRS
const adInteger=3
const adVarChar = 200
Set objRS = createobject("adodb.recordset")
With objRS.Fields
.Append "LID",adInteger
.Append "Location",adVarChar,100
End With
objRS.Open
With objRS
.AddNew Array("LID","Location"), Array(1,"Australia")
.AddNew Array("LID","Location"), Array(2,"Brazil")
'etc.
End With
The second test page will likely contain only this code:
<%
Response.Write "Request.Form(""location"") contains """ & _
Request.Form("location")
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"