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

Discussion in 'ASP General' started by David, Sep 18, 2007.

  1. David

    David Guest

    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
     
    David, Sep 18, 2007
    #1
    1. Advertising

  2. "David" <> wrote in message
    news:...
    > 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
     
    ThatsIT.net.au, Sep 18, 2007
    #2
    1. Advertising

  3. David

    Tim Slattery Guest

    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)

    http://members.cox.net/slatteryt
     
    Tim Slattery, Sep 18, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. FAQ server
    Replies:
    0
    Views:
    145
    FAQ server
    Aug 29, 2006
  2. FAQ server
    Replies:
    0
    Views:
    142
    FAQ server
    Oct 26, 2006
  3. FAQ server
    Replies:
    6
    Views:
    222
    Jonas Raoni
    Dec 25, 2006
  4. FAQ server
    Replies:
    26
    Views:
    301
    Dr J R Stockton
    Feb 26, 2007
  5. FAQ server
    Replies:
    2
    Views:
    135
    -Lost
    Apr 24, 2007
Loading...

Share This Page