Forums
This topic is locked
How to extract data from string to drop down menu?
Posted 22 years ago
1
has voted
22 years ago Chris Rowe posted:
I have a memo field seperated with commas with a value of Blue, Green, Yellow, Orange. How do I get that into a drop down menu so each color is a seperate choice? Thanks. I'm using ASP/Access. Replies
Replied 22 years ago
22 years ago Brent Colflesh replied:
Dear Crowe,
msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctsplit.asp
Regards,
Brent
msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctsplit.asp
Regards,
Brent
Replied 22 years ago
22 years ago Chris Rowe replied:
Thanks, bcolflesh. That explains how to get the data out of the string to me, but I still don't know how to put that into a menu drop down. Any ideas? Thanks again.
Replied 22 years ago
22 years ago Jørgen Emerslund replied:
Hi,
This code isn't bulletproof, and I haven't tested it, but I think it's about good
<pre id=code><font face=courier size=2 id=code>
<%
Dim Array
Dim iArrayLength, i
.........
Code for creating the 'best' recordset ever
.........
Array = Split( rsRec("Memofield"
, ","
iArrayLength = UBound(Array)
Response.Write(" <select name="""something"""> " )
For i = 0 to iArrayLength
Response.Write("<option value='" & Array(i) & "'>" & Array(i) & "</option>" & vbCr)
Next
Response.Write(" </select> " )
%> </font id=code></pre id=code>
Think that should do the trick, if I have understood you right...
This code isn't bulletproof, and I haven't tested it, but I think it's about good
<pre id=code><font face=courier size=2 id=code>
<%
Dim Array
Dim iArrayLength, i
.........
Code for creating the 'best' recordset ever
.........
Array = Split( rsRec("Memofield"


iArrayLength = UBound(Array)
Response.Write(" <select name="""something"""> " )
For i = 0 to iArrayLength
Response.Write("<option value='" & Array(i) & "'>" & Array(i) & "</option>" & vbCr)
Next
Response.Write(" </select> " )
%> </font id=code></pre id=code>
Think that should do the trick, if I have understood you right...
Replied 22 years ago
22 years ago Chris Rowe replied:
Stanly,
That's exactly what I'm after. But the code you provided didn't work. I think it has something to do with the way your <select> tags are placed. Could you possibly look that over? Maybe give me another version? Thanks.
That's exactly what I'm after. But the code you provided didn't work. I think it has something to do with the way your <select> tags are placed. Could you possibly look that over? Maybe give me another version? Thanks.
Replied 22 years ago
22 years ago Jørgen Emerslund replied:
<%
Dim Array
Dim iArrayLength, i
.........
Code for creating the 'best' recordset ever
.........
Array = Split( rsRec("Memofield"
, ","
iArrayLength = UBound(Array)
Response.Write("<select>" )
For i = 0 to iArrayLength
Response.Write("<option value='" & Array(i) & "'>" & Array(i) & "</option>" & vbCr)
Next
Response.Write("</select>" )
%>
Or you could do something like this, even:
<select>
<%
Dim Array
Dim iArrayLength, i
.........
Code for creating the 'best' recordset ever
.........
Array = Split( rsRec("Memofield"
, ","
iArrayLength = UBound(Array)
For i = 0 to iArrayLength
Response.Write("<option value='" & Array(i) & "'>" & Array(i) & "</option>" & vbCr)
Next
%>
</select>
Does this help? If not, can you give me a little description of what it does? The string is *only* seperated by commas, right, no spaces or anything? If there are more, you must edit the second parameter of the split function.
Stanly
Dim Array
Dim iArrayLength, i
.........
Code for creating the 'best' recordset ever
.........
Array = Split( rsRec("Memofield"


iArrayLength = UBound(Array)
Response.Write("<select>" )
For i = 0 to iArrayLength
Response.Write("<option value='" & Array(i) & "'>" & Array(i) & "</option>" & vbCr)
Next
Response.Write("</select>" )
%>
Or you could do something like this, even:
<select>
<%
Dim Array
Dim iArrayLength, i
.........
Code for creating the 'best' recordset ever
.........
Array = Split( rsRec("Memofield"


iArrayLength = UBound(Array)
For i = 0 to iArrayLength
Response.Write("<option value='" & Array(i) & "'>" & Array(i) & "</option>" & vbCr)
Next
%>
</select>
Does this help? If not, can you give me a little description of what it does? The string is *only* seperated by commas, right, no spaces or anything? If there are more, you must edit the second parameter of the split function.
Stanly
Replied 22 years ago
22 years ago Chris Rowe replied:
Stanly,
That works great if I put that on a blank page but for some reason when I put it into my current page it generates errors like this:
Microsoft VBScript runtime error '800a000d'
Type mismatch
/alphadog/products/detail.asp, line 9
Here is the code that is on that page at line 9:
UCII_CartColNames = Array("ProductID","Quantity","Name","Price","Total"
It's using the UltraCart II, does that help? Thanks so much for all of your help.
That works great if I put that on a blank page but for some reason when I put it into my current page it generates errors like this:
Microsoft VBScript runtime error '800a000d'
Type mismatch
/alphadog/products/detail.asp, line 9
Here is the code that is on that page at line 9:
UCII_CartColNames = Array("ProductID","Quantity","Name","Price","Total"

It's using the UltraCart II, does that help? Thanks so much for all of your help.
Replied 22 years ago
22 years ago Jørgen Emerslund replied:
The mismatch is probably the array, which as you write it, is a 5-dimentional array(!)
You got a memofield, which got a string in it, with 5 elements seperated by commas, right? I understood it like in the drop-down, you wanted those 5 elements... Is this correct, or do you want all 5 elements in each line, with each line being a new record in the db?
The code should be able to adapt to both cases, but my code is for the first version...
You got a memofield, which got a string in it, with 5 elements seperated by commas, right? I understood it like in the drop-down, you wanted those 5 elements... Is this correct, or do you want all 5 elements in each line, with each line being a new record in the db?
The code should be able to adapt to both cases, but my code is for the first version...
Replied 22 years ago
22 years ago Chris Rowe replied:
First, let me say I'm very new to arrays and using them. Second, the array that you and I have been working on could have 1 element or many. It's a multiple select box where the administrator can choose which colors that specific product is available in. For example, a rubber chew toy for dogs could be available in black, green, red, blue. But a different chew toy could be available in just red. Does this make sense? I hope so. That's what I'm trying to do. Any more ideas? Thanks again.
Replied 22 years ago
22 years ago Jørgen Emerslund replied:
Could you mail me a copy of the file at
edata@emerslund.no
, so I could take a closer look at it? That would probably be the best way for me to make sure what is happening....
