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

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

am 18.09.2007 17:44:42 von davidgordon

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

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

am 18.09.2007 18:13:23 von me

"David" wrote in message
news:1190130282.701564.55390@z24g2000prh.googlegroups.com...
> 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

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

am 18.09.2007 18:15:29 von McKirahan

"David" wrote in message
news:1190130282.701564.55390@z24g2000prh.googlegroups.com...
> 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

Will this get you started:



<%
Option Explicit
Dim arrORD()
Dim intORD
Dim strORD
strORD = Request.Form("your_textarea")
If strORD <> "" Then
arrORD = Split(strORD," x ")
For intORD = 0 To UBound(arrORD)
Response.Write _
" Product Code = " & arrORD(0) _
" Product Qty = " & arrORD(1)
Next
End If
%>

>
> Load Product Code & Product Qty into the Database
> where ...........................
>
> Then go to the next line and load into database

What database?

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

am 18.09.2007 18:16:26 von McKirahan

"McKirahan" wrote in message
news:PImdnUxAhuhdZXLbnZ2dneKdnZydnZ2d@comcast.com...
> "David" wrote in message
> news:1190130282.701564.55390@z24g2000prh.googlegroups.com...
> > 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
>
> Will this get you started:
>
>
>
> <%
> Option Explicit
> Dim arrORD()
> Dim intORD
> Dim strORD
> strORD = Request.Form("your_textarea")
> If strORD <> "" Then
> arrORD = Split(strORD," x ")
> For intORD = 0 To UBound(arrORD)
> Response.Write _
> " Product Code = " & arrORD(0) _
> " Product Qty = " & arrORD(1)
> Next
> End If
> %>
>
> >
> > Load Product Code & Product Qty into the Database
> > where ...........................
> >
> > Then go to the next line and load into database
>
> What database?
>

Oops:

Response.Write _
" Product Code = " & arrORD(1) _
" Product Qty = " & arrORD(0)

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

am 18.09.2007 18:16:39 von Tim Slattery

David wrote:

>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)

--
Tim Slattery
MS MVP(DTS)
Slattery_T@bls.gov
http://members.cox.net/slatteryt

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

am 18.09.2007 18:49:22 von McKirahan

"McKirahan" wrote in message
news:GoGdneUEls1lZXLbnZ2dnUVZ_gydnZ2d@comcast.com...
> "McKirahan" wrote in message
> news:PImdnUxAhuhdZXLbnZ2dneKdnZydnZ2d@comcast.com...
> > "David" wrote in message
> > news:1190130282.701564.55390@z24g2000prh.googlegroups.com...
> > > 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
> >
> > Will this get you started:

[snip]

Oops, again. Try this:



Products.htm