Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 fill listbox with db values
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

e3stone
Average Member

USA
885 Posts

Posted - 01 May 2001 :  09:04:17  Show Profile  Send e3stone an AOL message
I know how to fill the list box from the db, but here's my problem:
I'm using this code to populate the list box:

quote:
<select name="select1">
<% For intSelect1Count = 1 to rs.recordcount
response.write("<option value=" & rs("type") & ">" & rs("type") & "</option>")
rs.movenext
Next
rs.movefirst
%>
</select>

now, I'm filling the list box with employment category values, like "Database Administrator", "Accounting", "Software"
but, on the search result page with I do a request.form("select1") and I've chosen "Database Administrator" it only returns "Database"
I was doing the search on the database with this statement:
quote:
" WHERE [SKILL.TYPE] like '%" & request.form("select1") & "%'"


but, that will return "Database Administrator", "Database Assistant", and everything else that starts with "Database"

How can I return just the records which have "Database Administrator"??

do I have to trim() that 'value=" & rs("type")' ??

I'm stuck here. Any help would be great

<-- Eric -->


http://insidewaco.com/forum

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 01 May 2001 :  10:06:16  Show Profile  Visit HuwR's Homepage
I think the problem is the space in the value.

what does it think request.form("select1") is equal to?

Go to Top of Page

e3stone
Average Member

USA
885 Posts

Posted - 01 May 2001 :  10:28:33  Show Profile  Send e3stone an AOL message
Yeah, the space is the problem. If I pick "Database Administrator" and search that, request.form("select1") has a value of "Database"

How do I make it where the value passed is "Database Administrator"?

<-- Eric -->


http://insidewaco.com/forum

Edited by - e3stone on 01 May 2001 11:49:32
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 01 May 2001 :  13:22:01  Show Profile  Visit HuwR's Homepage
try doing something like

response.write("<option value=" & replace(rs("type")," ","_") & ">" & rs("type") & "</option>")


and then

" WHERE [SKILL.TYPE] like '%" & replace(request.form("select1"),"_"," ") & "%'"

Go to Top of Page

jasonterryinc
Starting Member

USA
1 Posts

Posted - 01 May 2001 :  13:37:03  Show Profile  Visit jasonterryinc's Homepage
To pass a value with a space in it, you must make sure that the value="" has the quotes (or single ticks) around it. Looking at your code, you are not including quotes around the values you are pulling from your database.

You only need to update one line and it will work. Copy and paste the following line over the corresponding line in your code:

response.write("<option value='" & rs("type") & "'>" & rs("type") & "</option>")


Go to Top of Page

e3stone
Average Member

USA
885 Posts

Posted - 01 May 2001 :  14:18:46  Show Profile  Send e3stone an AOL message
Thanks Huw, that works. I just changed it to
quote:
[SKILL.TYPE] = '" & replace(request.form("select6"),"_"," ") & "'"


so it wouldn't return everything that started with "Database"

<-- Eric -->


http://insidewaco.com/forum
Go to Top of Page

e3stone
Average Member

USA
885 Posts

Posted - 01 May 2001 :  14:24:16  Show Profile  Send e3stone an AOL message
yeah Jason, that was my problem. grrrr, can't believe that I (and Huw) went through all that because of a silly " ' " mark. Oh well, now I know

<-- Eric -->


http://insidewaco.com/forum
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 01 May 2001 :  16:00:13  Show Profile  Visit HuwR's Homepage
my eyes are obvioysly getting bad, missed it when I looked

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.36 seconds. Powered By: Snitz Forums 2000 Version 3.4.07