ASP UPDate database looping through form fields

Discussion in 'ASP General' started by Emmett Power, May 6, 2004.

  1. Emmett Power

    Emmett Power Guest

    Hi,

    I have a small online survey in two parts designed to allow users to
    rank a few organisations that they have dealings with from a large
    list of organisations. I want the users to be able to rank a number
    of organisations at the same time rather than going through a form for
    each one.

    At the moment the survey has two pages. The first page allows the user
    to select a number of organisations from the list. This selection is
    saved in a table in an Access database with five fields: ID, User,
    Organisation and Ranking.

    The second page loops through the data from the database selected by
    user and presents the list of organisations in a table with a row for
    each record. The table has a ranking field for each organisation. The
    user enters numeric data in this field to rank the organisation.

    So far so good. Where I am having problems is in updating the database
    with the data from the form. What I need to do is loop through each
    line of the table on the form, select the record from the database,
    update it and then move to the next item.

    The form has a field for each record with the same name so using
    Request.Form("FieldName") to grab the data from the form doesn't seem
    to work.

    I am sure that there must be a way of achieving what I want do: but I
    can't get it.

    I'd appreciate any suggestions or pointers.

    Thanks in advance for any help.

    Regards


    Emmett Power
    Emmett Power, May 6, 2004
    #1
    1. Advertising

  2. Emmett Power

    Steven Burn Guest

    How about;

    <%
    strString1 = Request.form("Ima_Field")

    Do Until rst.eof
    rst("TheField")=strString1
    rst.MoveNext
    Loop
    %>

    --

    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!


    "Emmett Power" <> wrote in message
    news:...
    > Hi,
    >
    > I have a small online survey in two parts designed to allow users to
    > rank a few organisations that they have dealings with from a large
    > list of organisations. I want the users to be able to rank a number
    > of organisations at the same time rather than going through a form for
    > each one.
    >
    > At the moment the survey has two pages. The first page allows the user
    > to select a number of organisations from the list. This selection is
    > saved in a table in an Access database with five fields: ID, User,
    > Organisation and Ranking.
    >
    > The second page loops through the data from the database selected by
    > user and presents the list of organisations in a table with a row for
    > each record. The table has a ranking field for each organisation. The
    > user enters numeric data in this field to rank the organisation.
    >
    > So far so good. Where I am having problems is in updating the database
    > with the data from the form. What I need to do is loop through each
    > line of the table on the form, select the record from the database,
    > update it and then move to the next item.
    >
    > The form has a field for each record with the same name so using
    > Request.Form("FieldName") to grab the data from the form doesn't seem
    > to work.
    >
    > I am sure that there must be a way of achieving what I want do: but I
    > can't get it.
    >
    > I'd appreciate any suggestions or pointers.
    >
    > Thanks in advance for any help.
    >
    > Regards
    >
    >
    > Emmett Power
    Steven Burn, May 6, 2004
    #2
    1. Advertising

  3. Emmett Power

    TLowe Guest

    Hello Emmett
    Try this!

    <HTML>
    <HEAD>
    </HEAD>
    <BODY><%
    Dim Item
    response.write "<TABLE cellSpacing=0 cellPadding=0 width=715 border=0>"
    response.write "<Th align=center vAlign=top WIDTH=33% colSpan=3>Key</TD> "
    response.write "<Th align=right vAlign=top WIDTH=33% colSpan=3>Item</TD> "
    response.write "<Th align=right vAlign=top WIDTH=33% colSpan=3>Count</TD>
    "
    Response.Write "<tr><TD>"

    For Each Item in Request.Form

    response.write "<TD align=left vAlign=top WIDTH=33% colSpan=3> "
    Response.Write Request.Form.Key(Item) & ": " & "</td><TD>"
    response.write "<TD align=left vAlign=top WIDTH=33% colSpan=3> "
    Response.Write Request.Form.Item(Item) & " " & "</td><TD>"
    response.write "<TD align=left vAlign=top WIDTH=33% colSpan=3> "
    Response.Write Request.Form.Item(Item).Count & "</td></tr><tr><TD>"


    Next
    Response.Write "</TABLE> "


    %>
    </BODY>

    </HTML>

    "Emmett Power" <> wrote in message
    news:...
    Hi,

    I have a small online survey in two parts designed to allow users to
    rank a few organisations that they have dealings with from a large
    list of organisations. I want the users to be able to rank a number
    of organisations at the same time rather than going through a form for
    each one.

    At the moment the survey has two pages. The first page allows the user
    to select a number of organisations from the list. This selection is
    saved in a table in an Access database with five fields: ID, User,
    Organisation and Ranking.

    The second page loops through the data from the database selected by
    user and presents the list of organisations in a table with a row for
    each record. The table has a ranking field for each organisation. The
    user enters numeric data in this field to rank the organisation.

    So far so good. Where I am having problems is in updating the database
    with the data from the form. What I need to do is loop through each
    line of the table on the form, select the record from the database,
    update it and then move to the next item.

    The form has a field for each record with the same name so using
    Request.Form("FieldName") to grab the data from the form doesn't seem
    to work.

    I am sure that there must be a way of achieving what I want do: but I
    can't get it.

    I'd appreciate any suggestions or pointers.

    Thanks in advance for any help.

    Regards


    Emmett Power
    TLowe, May 6, 2004
    #3
  4. Emmett Power

    Dominique Guest

    Personally, i think the best solution is:
    after the user selects that they want eg. 5 items


    for each item you print out, give it an incremental suffix e.g "_" & i

    like so:
    maxItems = Request.Form("num")

    for i = 1 to maxItems
    response.write "<blah blah blah field name='fld_" & i & "'>"

    you know the rest..
    next

    on ur post you send ur maxitems value
    and on ur transaction page you simply loop through the items that were sent
    eg.

    for i = 1 to maxItems
    strSentField = Request.form("fld_"&i)
    next

    ya know?


    "Emmett Power" <> wrote in message
    news:...
    > Hi,
    >
    > I have a small online survey in two parts designed to allow users to
    > rank a few organisations that they have dealings with from a large
    > list of organisations. I want the users to be able to rank a number
    > of organisations at the same time rather than going through a form for
    > each one.
    >
    > At the moment the survey has two pages. The first page allows the user
    > to select a number of organisations from the list. This selection is
    > saved in a table in an Access database with five fields: ID, User,
    > Organisation and Ranking.
    >
    > The second page loops through the data from the database selected by
    > user and presents the list of organisations in a table with a row for
    > each record. The table has a ranking field for each organisation. The
    > user enters numeric data in this field to rank the organisation.
    >
    > So far so good. Where I am having problems is in updating the database
    > with the data from the form. What I need to do is loop through each
    > line of the table on the form, select the record from the database,
    > update it and then move to the next item.
    >
    > The form has a field for each record with the same name so using
    > Request.Form("FieldName") to grab the data from the form doesn't seem
    > to work.
    >
    > I am sure that there must be a way of achieving what I want do: but I
    > can't get it.
    >
    > I'd appreciate any suggestions or pointers.
    >
    > Thanks in advance for any help.
    >
    > Regards
    >
    >
    > Emmett Power
    Dominique, May 6, 2004
    #4
  5. Emmett Power

    Emmett Power Guest

    Guys,

    Thanks for the suggestions. I'm going to try them out this weekend.

    Regards

    Emmett


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Emmett Power, May 7, 2004
    #5
    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. Aemca
    Replies:
    1
    Views:
    561
    Aemca
    Jul 22, 2003
  2. =?Utf-8?B?VGltOjouLg==?=

    Looping through Database??

    =?Utf-8?B?VGltOjouLg==?=, Jun 14, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    718
    =?Utf-8?B?VGltOjouLg==?=
    Jun 14, 2004
  3. ML
    Replies:
    1
    Views:
    847
  4. Roy Adams

    looping through records and only update one

    Roy Adams, Aug 15, 2004, in forum: ASP General
    Replies:
    4
    Views:
    173
  5. Aaron
    Replies:
    2
    Views:
    519
    dhtml
    Apr 10, 2011
Loading...

Share This Page