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!

using replace but needing help 1

Status
Not open for further replies.

tyutghf

Technical User
Apr 12, 2008
258
GB
I am using replace to grab comma separated data and place this into a select command.

Code:
if not rs("size") = "" then
Response.write "Size: <select name='size'><option value=''>Please select</option><option>" & replace(rs("size"),",","</option><option>") & "</option></select><br /><br />"
end if

The value in the database would be like large,medium,small.

This works fine and produces the html

<select name='size'>
<option value=''>Please select</option>
<option>Large</option>
<option>Medium</option>
<option>Small</option>
</select>

That's been working fine but IE is having an issues with values not being specified on the options.

I am struggling to figure out how to take the CSV from the database to create a select including values on the options.

Can anyone help?

Thanks
 
Something like this?


Code:
<%
dim text, a, x
text= "Small,Medium,Large"

a=Split(text, ",")
response.write "<form>" & vbCRLF
response.write "<select>" & vbCRLF
for each x in a
  response.write "<option value='" & x & "'>"& x & "</option>"  & vbCRLF
next
response.write "</select>" & vbCRLF
response.write "</form>" & vbCRLF
%>
 
Thanks for your help, how should the data be stored? Some of the fields such as color may have 10 varieties.
 
In general, storing data like

productid color
12 green, red, brown
14 blue, tan
134 red, orange

is less preferable to something like

productid color
12 red
12 green
134 orange
12 brown
14 blue
134 red
14 blue

Or even a third table with colors and color codes and then color codes instaed of names in the above table.

If I want to know all the colors product 12 comes in so I can build a select box for ordering using the first table, you have already discovered that you have to manipulate what comes back from the query and it can be a pain.

Using the second table the query

select color
from table
where productid= 12

gives me a recordset that looks like

red
green
brown

instead of green, red, brown

and is easier to work with.

If you have a request to see all the products that come in red, you are either in for some coding or going to learn about LIKE and wildcards using the first table, where the second table is a simple

select productid
from table
where color= 'red'

It's data normalization. It's complex and I don't profess to understand much of it at all.

If you want to work on that aspect of things, I would repost (in probably the database area) with a fuller schema of what you have and let some of the people who know a little about structure have a crack.

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top