a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Hosting from $3.99 per month!

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions. dd

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

Working with comma delimited data

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Working with comma delimited data
Page: [1]
 
Aelaron

 

Posts: 223
Joined: 6/8/2004
Status: offline

 
Working with comma delimited data - 1/16/2005 12:27:08   
Gang,

I have a field in my database that stores a set of numbers seperated by comma's.

I want to try and achieve a couple of things:

1. I want to be able to seperate these values in to individual numbers and assign this number to a variable as well as fill a text box with the number.

2. My page needs to be able to count how many numbers there are. It can be anywhere from 1 to 12 of these numbers represented like: 1,3,4,6 or 1,15,23 etc...... and generate 1 text box for each number to go in.

3. Then I want to update my table in certain columns depending upon the value of each number.

I have no idea where to start with this. The page where all this needs to happen is recieving the ID of the record containing my comma delimited values as a submission from another form.

As always, your help is greatly appreciated,

JB
Spooky

 

Posts: 26617
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Working with comma delimited data - 1/16/2005 14:17:20   
Say.....

<%
Input = "1,3,4,6"
arrInput = Split(Input,",")

For a = 0 to uBound(arrInput)
response.write "Input "&a&"="& arrInput(a) & "<br>"
Next
%>




_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to Aelaron)
Aelaron

 

Posts: 223
Joined: 6/8/2004
Status: offline

 
RE: Working with comma delimited data - 1/16/2005 14:37:37   
I seem to understand what you have offered up Spooky....

Here's the code I used:

<%

Input = request.form("SlotNumber")
arrInput = Split(Input,",")

For a = 0 to uBound(arrInput)
response.write "Input "&a&"="& arrInput(a) & "<br>"
Next

%>

But I don't quite understand the output:

Input 0=2%2C4%2C6%2C

the numbers 2, 4, 6 are my numbers but am unsure of the extra stuff.

Please advise,

JB


(in reply to Spooky)
Spooky

 

Posts: 26617
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Working with comma delimited data - 1/16/2005 14:40:38   
Looks like the input is encoded.
When the data is entered into the database, you must be using urlencode?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to Aelaron)
Aelaron

 

Posts: 223
Joined: 6/8/2004
Status: offline

 
RE: Working with comma delimited data - 1/16/2005 14:44:22   
Is that something that is configurable by me? It sounds greek though.

JB

(in reply to Spooky)
Spooky

 

Posts: 26617
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Working with comma delimited data - 1/16/2005 14:47:08   
How do you insert the data into the database?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to Aelaron)
Aelaron

 

Posts: 223
Joined: 6/8/2004
Status: offline

 
RE: Working with comma delimited data - 1/16/2005 14:50:36   
Here's my insert code for the information I am trying to use:


mySQL4 = "INSERT INTO CriticalProjects ( TW_LotID, ProjectOwner, OwnerPager, ContactInfo, ProjectDate, LotNumber, SlotNumber, Scanner, Layer, Product, Reticle, ScannerInstructions, Purpose, ScannerDone, SemF5, TgtStructure, TgtValue, SemDone, SemInstructions, Priority) VALUES"
mySQL4 = mySQL4 & " ('"& Request.Form("Lot_ID") &"','"& Request.Form("ProjectOwner") &"', '"& Request.Form("OwnerPager") &"', '"& Request.Form("ContactInfo") &"', '"& Request.Form("ProjectDate") &"', '"& Request.Form("LotNumber") &"', '"& Request.Form("SlotNumber") &"', '" & Request("Scanner") & "', '"& Request.Form("Layer") &"', '"& Request.Form ("Product") &"', '"& Request.Form ("Reticle") &"', '"& Request.Form ("ScannerInstructions") &"', '"& Request.Form ("Purpose") &"', '"& Request.Form ("ScannerNeeded") &"', '"& Request.Form ("SemF5") &"', '"& Request.Form ("TgtStructure") &"', '"& Request.Form ("TgtValue") &"', '"& Request.Form ("SemNeeded") &"', '"& Request.Form ("SemInstructions") &"', 'B')"
'response.write mySQL4
conntemp.execute(mySQL4)



JB

(in reply to Spooky)
Aelaron

 

Posts: 223
Joined: 6/8/2004
Status: offline

 
RE: Working with comma delimited data - 1/16/2005 15:00:59   
I believe I found the problem.....

In the form that was submitting to the input page, I had:

<%=FP_FieldUrl(fp_rs,"SlotNumber")%>

instead of

<%=FP_FieldVal(fp_rs,"SlotNumber")%>

With this fix, my results are:

Input 0=2
Input 1=4
Input 2=6
Input 3=

Thanks Spooky

(in reply to Aelaron)
Spooky

 

Posts: 26617
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Working with comma delimited data - 1/16/2005 16:30:42   
Coreect - that code would have encoded it

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to Aelaron)
Aelaron

 

Posts: 223
Joined: 6/8/2004
Status: offline

 
RE: Working with comma delimited data - 1/17/2005 15:43:21   
Spooky,

I just realized something, that you may know how to help. If you notice, my output for removing the commas looked like:

Input 0=2
Input 1=4
Input 2=6
Input 3=

If you hadn't noticed before, I get Input3 =

It seems that the code I use to originally generate the SlotNumber sticks an extra comma at the end.

I can think of 2 possible ways to fix this, one would be to have code that cuts off the last comma, or else fix my code so that it doesn't generate the last comma.

Here is the code, and please don't snicker at it's immense size. :) It was the only way I could think of generating the results I wanted. If you have a better way of achieving the desired result, I am all ears.


<%


m = 0
for m = 1 to 26
	If m < 26 then
		'z = m + 1
		strSlotA = request.form ("Slot_Value_"&m)
			If strSlotA = "True" then
				a = m
				For n = (m+1) to 26
				If n < 26 then
				'z = n + 1
				strSlotB = request.form ("Slot_Value_"&n)
					If strSlotB = "True" then
						b = n
						For o = (n+1) to 26
						If o < 26 then
						'z = o + 1
						strSlotC = request.form ("Slot_Value_"&o)
							If strSlotC = "True" then
								c = o
								For p = (o+1) to 26
								If p < 26 then
								'z = p + 1
								strSlotD = request.form ("Slot_Value_"&p)
									If strSlotD = "True" then
										d = p
										For q = (p+1) to 26
										If q < 26 then
										'z = q + 1
										strSlotE = request.form ("Slot_Value_"&q)
											If strSlotE = "True" then
												e = q
												For r = (q+1) to 26
												If r < 26 then
												'z = r + 1
												strSlotF = request.form ("Slot_Value_"&r)
													If strSlotF = "True" then
														f = r
														For s = (r+1) to 26
														If s < 26 then
														'z = s + 1
														strSlotG = request.form ("Slot_Value_"&s)
															If strSlotG = "True" then
																g = s
																For t = (s+1) to 26
																If t < 26 then
																'z = t + 1
																strSlotH = request.form ("Slot_Value_"&t)
																	If strSlotH = "True" then
																		h = t
																		For u = (t+1) to 26
																		If u < 26 then
																		'z = u + 1
																		strSlotI = request.form ("Slot_Value_"&u)
																			If strSlotI = "True" then
																			i = u
																			For v = (u+1) to 26
																			If v < 26 then
																			'z = v + 1
																			strSlotJ = request.form ("Slot_Value_"&v)
																				If strSlotJ = "True" then
																				j = v
																				For w = (v+1) to 26
																				If w < 26 then
																				'z = w + 1
																				strSlotK = request.form ("Slot_Value_"&w)
																					If strSlotK = "True" then
																					k = w
																					For x = (w+1) to 26
																					If x < 26 then
																					'z = x + 1
																					strSlotL = request.form ("Slot_Value_"&x)
																						If strSlotL = "True" then
																						l = x
																						Else
																						End If
																						Wafers = a&","&b&","&c&","&d&","&e&","&f&","&g&","&h&","&i&","&j&","&k&","&l
																					Else
																					End If
																					Next
																					Exit For
																				Else
																				End If
																				Wafers = a&","&b&","&c&","&d&","&e&","&f&","&g&","&h&","&i&","&j&","&k
																			Else
																			End If
																			Next
																			Exit For
																		Else
																		End If
																		Wafers = a&","&b&","&c&","&d&","&e&","&f&","&g&","&h&","&i&","&j
																	Else
																	End If
																	Next
																	Exit For
																Else
																End If
																Wafers = a&","&b&","&c&","&d&","&e&","&f&","&g&","&h&","&i
															Else
															End If
															Next
															Exit For
														Else
														End If
														Wafers = a&","&b&","&c&","&d&","&e&","&f&","&g&","&h
													Else
													End If
													Next
													Exit For
												Else
												End If
												Wafers = a&","&b&","&c&","&d&","&e&","&f&","&g											
												Else
											End If
											Next
											Exit For
										Else
										End If
										Wafers = a&","&b&","&c&","&d&","&e&","&f									
										Else
									End If
									Next
									Exit For
								Else
								End If
								Wafers = a&","&b&","&c&","&d&","&e
							Else
							End If
							Next
							Exit For
						Else
						End If
						Wafers = a&","&b&","&c&","&d
					Else
					End If
					Next
					Exit For
				
				Else
				End If
				Wafers = a&","&b&","&c
				
			Else
			End If
			Next
			Exit For
		Else
		End If
		Wafers = a&","&b
		
	Else
	End If
	Next
	Exit For
Else
End If
Wafers = a
End If
Next

SlotNumber = Wafers

%>



Thanks again for all the help,

JB

(in reply to Spooky)
Spooky

 

Posts: 26617
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Working with comma delimited data - 1/17/2005 16:45:17   
WOAH! <snicker....> :)

If you are just after a comma delimited selection, ie, which check boxes did a person select, then just using a bunch of check boxes with the same name should suffice.
Is that what you are doing?



_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to Aelaron)
Aelaron

 

Posts: 223
Joined: 6/8/2004
Status: offline

 
RE: Working with comma delimited data - 1/17/2005 16:58:43   
OK....Here's the deal:

I have a box of items, numbered 1 through 25. Each of them have a column associated to them in my database table.

The website user selects the items he wants to use by using check boxes and then submits them to a form that he fills out regarding what he is going to do with them.

Each checkbox is called: Slot_Value_n where n is the number 1 through 25.

My code is an attempt to cycle through all the possible check boxes and remember which ones were checked.

It then groups the item numbers together in one field called SlotNumber.

So a result of Slot_Value_1 = "TRUE", Slot_Value_4 = "TRUE", and Slot_Value_7 = "TRUE" should result in a SlotNumber value of 1,4,7

However, my code generates a result of 1,4,7, (notice the comma at the end)

I am sure that there is a simpler way, I just don't know what it is.

Thanks again,

JB

(in reply to Spooky)
Spooky

 

Posts: 26617
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Working with comma delimited data - 1/17/2005 17:16:43   
So, as above, name all of the check boxes "Slot_Value"
Give each of them a value, 1-25

When a user selects them, you end up with a comma delimited list and very little code (all you need is the request form)

To trim the last comma :
SlotNumber = left(Wafers, len(Wafers)-1)

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to Aelaron)
Aelaron

 

Posts: 223
Joined: 6/8/2004
Status: offline

 
RE: Working with comma delimited data - 1/18/2005 8:29:16   
Spooky...

You've got to be kidding me.....

Let me see if I got this right:

If I name all the checkboxes the same name and give them values 1 through 25 and the user selects checkboxes 1, 4, and 7 that when I request.form("Slot_Value") I will get a value of 1,4,7?

JB

(in reply to Spooky)
Spooky

 

Posts: 26617
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Working with comma delimited data - 1/18/2005 10:05:03   
Yep :)

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to Aelaron)
Aelaron

 

Posts: 223
Joined: 6/8/2004
Status: offline

 
RE: Working with comma delimited data - 1/18/2005 10:23:41   
Something is wrong here....that is just TOO easy! :)

Thanks Spooky!

JB

(in reply to Spooky)
Aelaron

 

Posts: 223
Joined: 6/8/2004
Status: offline

 
RE: Working with comma delimited data - 1/18/2005 15:14:35   
Now that I have named them the same, how can I force them to be checked?

Here's the deal.....

I now have my Slots in comma delimited form. The user wants to return to the page where he selected his slots and select one more. How can I make the original ones he checked to still be checked when he returns to that page?

I can seperate the comma delimited data, but how do I refer to the check box associated to those particular slots now that all the checkboxes are the same name?

JB

(in reply to Aelaron)
BeTheBall

 

Posts: 6385
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Working with comma delimited data - 1/18/2005 18:45:17   
Guessing this is not the most efficient code, but should do what you need:
<%
myStr = yourDBValue
arrStr = Split(myStr,",")
%> 

<input type = 'checkbox' name = 'myBox' <% For each i in arrStr
If i = 1 Then
Response.write " Checked"
End If
Next
%>
value="1"><br>
<input type = 'checkbox' name = 'myBox' <% For each i in arrStr
If i = 2 Then
Response.write " Checked "
End If
Next
%>
 value="2"><br>
<input type = 'checkbox' name = 'myBox' <% For each i in arrStr
If i = 3 Then
Response.write " Checked "
End If
Next
%>
 value="3"><br>
<input type = 'checkbox' name = 'myBox' <% For each i in arrStr
If i = 4 Then
Response.write " Checked "
End If
Next
%>
 value="4"><br>
<input type = 'checkbox' name = 'myBox' <% For each i in arrStr
If i = 5 Then
Response.write " Checked "
End If
Next
%>
 value="5"><br>
<input type = 'checkbox' name = 'myBox' <% For each i in arrStr
If i = 6 Then
Response.write " Checked "
End If
Next
%>
 value="6"><br>
<input type = 'checkbox' name = 'myBox' <% For each i in arrStr
If i = 7 Then
Response.write " Checked "
End If
Next
%>
 value="7">


What it does is as it writes each checkbox, it loops through the values of your comma-delimited string (which we have put into an array called arrStr). If it finds a value in the array that matches the value of the checkbox, it then marks the box checked. The inefficieny, which I don't know how to avoid, is that it runs through the array 25 times, i.e., once for each checkbox.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to Aelaron)
Page:   [1]
OutFront Discoveries

All Forums >> Web Development >> ASP and Database >> Working with comma delimited data
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts