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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RETRIEVING VALUE OF LIST BOX CONTROL 1

Status
Not open for further replies.

Charlix

Programmer
Nov 19, 2002
85
US

I have an ASP page that has a listbox control that is populated with a list of 'clients' and 'title' by the following code.
---------------------------------------------------
Set rs = Server.CreateObject("ADODB.Recordset")
conn = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=C:\db1.mdb"
sql = "SELECT [Title] FROM [Client Table] ORDER BY [Title] "
rs.open sql, conn

Do Until rs.EOF

dim StringS
stringS = stringS & &quot;<option value=&quot; & rs(&quot;Title&quot;) & &quot;>&quot; & rs(&quot;Title&quot;) & &quot; </option>&quot;

rs.MoveNext

Loop %>

<select name=&quot;Operation1&quot; size=&quot;1&quot;>
<option value=&quot;&quot;>Select Value</option>
&quot;<%=stringS%>&quot;
</select>


<SCRIPT LANGUAGE=&quot;VBScript&quot;>
MsgBox request.Operation1.Value & &quot;: &quot; & &quot;<%=stringS%>&quot;
</SCRIPT>

-----------------------------------------------------------

The list box is populated correctly, but I find that when I use the 'Post' method to send a user selection to next page only the first word in a multiword selection is sent. When I check with a 'MsgBox' I find that the 'request.Operation1.Value' returns only the first word in a multiword selection while the '<%=strings%>' returns the entire string.

I want to be able to have the user's selection from the combobox be complete and not only the first word. What do I have to do?

Thanks for any help.

Charlix
 
As Bastien pointed out yesterday (thread333-781741), you will need to encapsulate the value in quotes. Change it like this:

dim StringS
stringS = stringS & &quot;<option value='&quot; & rs(&quot;Title&quot;) & &quot;'>&quot; & rs(&quot;Title&quot;) & &quot; </option>&quot;

Otherwise, it is only picking up any characters prior to the first space.

-----------------------------------------------------------------------------------------------------
&quot;If you can't explain something to a six-year-old, you really don't understand it yourself.&quot;
-- Albert Einstein
 
Thanks chopstik for catching my mistake. I left out the single quotes. I put them in and it works fine.
Thanks again.
Charlix
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top