ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 11th, 2005, 02:35 AM
AB_Jeroen AB_Jeroen is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 28 AB_Jeroen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 17 m 40 sec
Reputation Power: 0
get a POST array

hello,

I've got a form, that form has (for example) 8 fields
(can be less, or more), and thats exactly whats the
problem

Sample:
<input type='text' name='array' value='Jeroen'>
<input type='text' name='array' value='Willem'>
<input type='text' name='array' value='Hanibal'>

how do I get this array, after the POST, and can I
create 1 variabel, who contains the array?
Dim array_posted <- ?

also I need to know how long the array is, so I can
create a loop for inserting in the database

1. create array
2. length of array
3. output of array

Reply With Quote
  #2  
Old March 11th, 2005, 09:31 AM
Anibal Anibal is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 176 Anibal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 4 h 20 m 48 sec
Reputation Power: 14
Hello Again...this is a monopoly of answers!!

Your problem is simpler than it looks. When you do that (many fields with the same name) you get automaticaly a variable named after the field (in your case: array) that is posted to the recipient ASP with all the values separated by commas. So, in the recipient ASP jus go:

Code:
 
Dim names, name
 
names = split(Request.Form("array"), ",")
for each name in names
	'place code to insert in DB with name
next


This way you don't care how many elements the array actually has. If you want to know..use the function Ubound(<array>). That returns the amount of elements in the array.

Good Luck!!

Anibal.

Reply With Quote
  #3  
Old March 14th, 2005, 02:14 AM
AB_Jeroen AB_Jeroen is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 28 AB_Jeroen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 17 m 40 sec
Reputation Power: 0
Quote:
Originally Posted by Anibal
Hello Again...this is a monopoly of answers!!

Your problem is simpler than it looks. When you do that (many fields with the same name) you get automaticaly a variable named after the field (in your case: array) that is posted to the recipient ASP with all the values separated by commas. So, in the recipient ASP jus go:

Code:
 
Dim names, name
 
names = split(Request.Form("array"), ",")
for each name in names
	'place code to insert in DB with name
next


This way you don't care how many elements the array actually has. If you want to know..use the function Ubound(<array>). That returns the amount of elements in the array.

Good Luck!!

Anibal.

omg nice, thanks men, I noticed that when I showed the array (respone.write) that all the fields where showen (1, 2, 3, 4)

never thougt of splitting them, ty

Reply With Quote
  #4  
Old March 28th, 2005, 03:09 PM
scollis scollis is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 1 scollis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 58 sec
Reputation Power: 0
Cool Possible Solution

If I have understood your problem correctly then this code should help.

dim Names, Name : Names = Split(Request.Form("Name"),", ")

for each Name in Names
Response.Write "Name=" & Name
next

<input type='text' name='name' value='Jeroen'>
<input type='text' name='name' value='Willem'>
<input type='text' name='name' value='Hanibal'>

Hope this helps.

Quote:
Originally Posted by AB_Jeroen
hello,

I've got a form, that form has (for example) 8 fields
(can be less, or more), and thats exactly whats the
problem

Sample:
<input type='text' name='array' value='Jeroen'>
<input type='text' name='array' value='Willem'>
<input type='text' name='array' value='Hanibal'>

how do I get this array, after the POST, and can I
create 1 variabel, who contains the array?
Dim array_posted <- ?

also I need to know how long the array is, so I can
create a loop for inserting in the database

1. create array
2. length of array
3. output of array

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > get a POST array


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap