Split Textarea (by lines), trim and save to Database

D

David

Hi,

I want to know if it is possible to do the following.

I have a form which lets users select a product, enter a quantity and
set the info into a Textarea field.
Each time the user hits the 'Set' button, it adds another line into
the Textarea, e.g.

______________________
5 x Product1
63 x Product2
115 x Product3
75 x Product 7
______________________

At present, I just have the data sent in an email, but now I need to
save each line into our database, linked to a specific PO Number.
Is there a way to strip the data in the Textarea into variables on the
next page like

Within a loop which runs through each line
Strip the product code and qty

Product Code = Product1
Product Qty = 5




Load Product Code & Product Qty into the Database
where ...........................

Then go to the next line and load into database

Appreciate your help on this

David
 
T

ThatsIT.net.au

David said:
Hi,

I want to know if it is possible to do the following.

I have a form which lets users select a product, enter a quantity and
set the info into a Textarea field.
Each time the user hits the 'Set' button, it adds another line into
the Textarea, e.g.

______________________
5 x Product1
63 x Product2
115 x Product3
75 x Product 7
______________________

At present, I just have the data sent in an email, but now I need to
save each line into our database, linked to a specific PO Number.
Is there a way to strip the data in the Textarea into variables on the
next page like

Within a loop which runs through each line
Strip the product code and qty

Product Code = Product1
Product Qty = 5




Load Product Code & Product Qty into the Database
where ...........................

Then go to the next line and load into database

Appreciate your help on this

David


You can use the textrange object
http://msdn2.microsoft.com/en-us/library/ms533042.aspx


but it would be easier to use a array to hold values not the textarea
 
T

Tim Slattery

David said:
Hi,

I want to know if it is possible to do the following.

I have a form which lets users select a product, enter a quantity and
set the info into a Textarea field.
Each time the user hits the 'Set' button, it adds another line into
the Textarea, e.g.

______________________
5 x Product1
63 x Product2
115 x Product3
75 x Product 7
______________________

At present, I just have the data sent in an email, but now I need to
save each line into our database, linked to a specific PO Number.
Is there a way to strip the data in the Textarea into variables on the
next page like

Within a loop which runs through each line
Strip the product code and qty

Product Code = Product1
Product Qty = 5

Aren't the lines separated by newline characters? Then - assuming your
ASP page is using VBScript - use the Split function
(http://msdn2.microsoft.com/en-us/library/0764e5w5.aspx) to break the
contents of the textarea into individual lines. If you using
Javascript to write your ASP code, it's the split method of the String
object (http://msdn2.microsoft.com/en-us/library/t5az126b.aspx)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top