Forums
This topic is locked
comma seperated values into an array
Posted 29 Aug 2007 20:53:34
1
has voted
29 Aug 2007 20:53:34 Simon Bloodworth posted:
HiI have a page that submits a number of chosen value via checboxes and when these are added to the DB they are seperated by a comma.
I need to be able to search my database by these values so need to seperate them so thought to put them in an array and then use it to search the db.
So far i can remove the commas but am having difficulty putting them into an array.
the first bit of code is this (to hopefully put thm in an array)
135 <%
136 Dim SearchString
137 Dim ItemArray()
138
139 SearchString = RsEmailer.Fields.Item("E_SearchString".value
140 ItemArray() = Split(SearchString,","
141
142 For i = 0 to Ubound(ItemArray())
143 itemarray() = itemarray(i)
144 response.write(itemarray)
145 next
146 %>
but i keep getting the error:
Subscript out of range
/remote/bfj/private/email1.asp, line 140
Wonderd if anyone could help
Simon
DWMX 2004 | ASP | VBScript
Replies
Replied 30 Aug 2007 23:26:15
30 Aug 2007 23:26:15 Lee Diggins replied:
Hi Simon
Try This:
<%
Dim SearchString
Dim ItemArray
SearchString = "1,2,3,4,5,6,7,8,9,10"
ItemArray = Split(SearchString,","
For i = 0 to Ubound(ItemArray)
Response.Write(itemarray(i) & "<br />"
Next
%>
Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
Try This:
<%
Dim SearchString
Dim ItemArray
SearchString = "1,2,3,4,5,6,7,8,9,10"
ItemArray = Split(SearchString,","
For i = 0 to Ubound(ItemArray)
Response.Write(itemarray(i) & "<br />"
Next
%>
Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
Replied 01 Sep 2007 14:35:01
01 Sep 2007 14:35:01 Simon Bloodworth replied:
thanks lee - that bit works like a charm now .
Just need to get my head round using that array to search through my DB - Im sure ill be back!
many thanks for your help
regards
Simon
DWMX 2004 | ASP | VBScript
Just need to get my head round using that array to search through my DB - Im sure ill be back!
many thanks for your help
regards
Simon
DWMX 2004 | ASP | VBScript