Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP UPDate database looping through form fields

Reply
Thread Tools

ASP UPDate database looping through form fields

 
 
Emmett Power
Guest
Posts: n/a
 
      05-06-2004
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
 
Reply With Quote
 
 
 
 
Steven Burn
Guest
Posts: n/a
 
      05-06-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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



 
Reply With Quote
 
 
 
 
TLowe
Guest
Posts: n/a
 
      05-06-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
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


 
Reply With Quote
 
Dominique
Guest
Posts: n/a
 
      05-06-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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



 
Reply With Quote
 
Emmett Power
Guest
Posts: n/a
 
      05-07-2004

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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
looping through json array loops through the characters instead ofthe values Aaron Javascript 2 04-10-2011 05:58 PM
Handling large batch looping database update process from ASP.NET page? ML ASP .Net 1 08-16-2005 10:03 AM
Re: Looping through Database?? Phil Winstanley [Microsoft MVP ASP.NET] ASP .Net 1 06-14-2004 12:22 PM
Looping through Database?? =?Utf-8?B?VGltOjouLg==?= ASP .Net 0 06-14-2004 09:34 AM
Looping through all the form fields in the code behind ? Aemca ASP .Net 1 07-22-2003 08:31 AM



Advertisments