ASP UPDate database looping through form fields

E

Emmett Power

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
 
S

Steven Burn

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!
 
T

TLowe

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>

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
 
D

Dominique

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?
 
E

Emmett Power

Guys,

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

Regards

Emmett
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top