Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Selection Combo Box!

Status
Not open for further replies.

garfield11

IS-IT--Management
Jul 4, 2002
44
SG
Hi all,

Here's my problem:

I'd a form page called "contactreport_add.asp" and had a drop down menu to display all Consultants' names with multiple selection (extract from database table Consultants).

Then I'd an action page called "contactreport_add_proc.asp" and I did this:

strSelectedTeams = Request.Form("ConsultantName")
arrSelectedTeams = Split(strSelectedTeams, ", ", -1, 1)

Ok lets say from that drop down list I selected Jane, Mary n Susan and insert them into the database. it works.

Now the problem is; if I had another page called "contactreport_view.asp" and I wanna retrieve n display just now that saved data from database, how can i do so?

Can anyone halp?

Thanks!

Love_Garfield
 
You mean printing out the selectbox in asp?

Let's say you have a recordset with all the items and your strSelectedTeams containing the ID's of the records that are selected.

strSelectedTeams = "," & strSelectedTeams & ","
with response
.write &quot;<select id=sel multiple>&quot; & vbcrlf
' rs.movefirst ' just to make sure unless it is a forward only recordset
do until rs.eof
.write &quot;<option value=&quot;&quot;&quot; & rs(&quot;id&quot;) & &quot;&quot;&quot;
if instr(1,strSelectedTeams,&quot;,&quot; & str(rs(&quot;id&quot;) & &quot;,&quot;,1)>0 then .write &quot; selected &quot;
.write &quot;>&quot;
.write rs(&quot;textvalue&quot;) & &quot;</option>&quot; & vbcrlf
rs.movenext
loop


I put a , before and after the strSelectedTeams so if id 1 and 3 were selected the string looks like this:
,1,3,
instr checkes if the current id is in the strSelectedTeams string so if the id would be 1 it checkes if &quot;,1,&quot; is in the string &quot;,1,3,&quot;.
 
sorry a typo, this line:
if instr(1,strSelectedTeams,&quot;,&quot; & str(rs(&quot;id&quot;) & &quot;,&quot;,1)>0 then .write &quot; selected &quot;
should be:
if instr(1,strSelectedTeams,&quot;,&quot; & str(rs(&quot;id&quot;)) & &quot;,&quot;,1)>0 then .write &quot; selected
 
Hi harmmejer,

Thanks for your reply but I now really very blur....

Ok I had this code in this page called &quot;contactreport_add.asp&quot;

<TD>Consultant Name :</TD>
<TD><SELECT name=&quot;Consultant&quot; multiple size=5>
<% While Not objRS3.EOF %>
<OPTION Value=&quot;<%= objRS3(&quot;Consultant&quot;) %>&quot;
<% If edit <> -1 Then
If objRS3(&quot;Consultant&quot;) = objRS(&quot;Consultant&quot;) Then
Response.Write &quot; SELECTED &quot;
End If
End If %> ><%= objRS3(&quot;ConsultantName&quot;) %></OPTION>
<% objRS3.MoveNext
Wend %></SELECT></TD>

Then I'd this code in &quot;contactreport_add_proc.asp&quot;:

Dim Consultant, arrSelectedTeams
Consultant= strProc(Request.Form(&quot;Consultant&quot;))
arrSelectedTeams = Split(Consultant, &quot;, &quot;, -1, 1)

Insert into Consultants (Consultant, ConsultantName, ...)
Values ('&quot; & Consultant & &quot;', '&quot; & ConsultantName & &quot;',...)

Lets say I select John, Mary n Johnny and it saves into the database with a separate commas (John,Mary,Johnny).

Ok now, I do have a page called &quot;contactreport_view.asp&quot; and I want to display just now that saved data like:

Consultant's Info:

Consultant Name: John
Mary
Johnny

So how am I going to do about it??


Also, another thing is in &quot;contactreport_add.asp&quot;, I have an edit button. How can I make the selected items highlighted?

Example:

Consultant Name: John <-- highlighted
Jane
Mary <-- highlighted
Johnny <-- highlighted
Alan


Sorry if I didn't explain my problems very clearly.

Thanks.

Love_Garfield
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top