Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 4th, 2004, 11:15 AM
Registered User
 
Join Date: May 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Forms Collection

I have an ASP page that is creating a table of inputs which are being
dynamically named based on the column values from the table.
Basically what I'm doing is iterating through my recordset and
writing out a table, i.e.,

Do While Not rsTemp.EOF
For Each objColumn In rsTemp.Fields
Response.Write "<input type='text' name='" & rsTemp("recordid")
rsTemp("objColumn.Name") & "' />"
Next
rsTemp.MoveNext
Loop

The problem doesn't come into play until I submit this form with
beaucoup fields in it. What I'm wanting to do is iterate through the
forms collection and parse back out both the form field name and the
form field value. So I try a couple of different ways to do that.

The first thing I do is the following:
Dim fieldCount = Request.Form.Count
For i = 1 to fieldCount
Response.Write Request.Form(i) & "<br />" & vbcrlf
Next

This works great for displaying the form field values in order, but
it won't show me the form field name.

So then I try this:
For Each frmField In Request.Form
Response.Write myItem & " #150; [" & Request.Form(myItem) & "]
<br />" & vbcrlf
Next

This works well for showing the name of the field as well as the
value, but with on major problem. While the first loop displayed the
field values in the correct order, the second loop appears to have
displayed them completely at random.
For example, lets say my form had 5 fields in it
named "1fname", "2fname", "3fname", "4fname" and "5fname".
The HTML output that my first ASP page creates would be something
along these lines (obviously shortened for this example)...
<table>
<tr>
<td><input type="text" name="1fname" value="Mark" /></td>
<td><input type="text" name="2fname" value="Todd" /></td>
<td><input type="text" name="3fname" value="Jim" /></td>
<td><input type="text" name="4fname" value="Steve" /></td>
<td><input type="text" name="5fname" value="Carl" /></td>
</tr>
</table>
By using array notation to iterate through the forms collection, the
loop will return the following
Mark
Todd
Jim
Steve
Carl

By using the For Each...In loop to iterate through the forms
collection, the results might be something like this...

Todd
Carl
Steve
Jim
Mark

WHY?


 
Old May 5th, 2004, 02:13 AM
Authorized User
 
Join Date: Jun 2003
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

I've been doing something similar. The reason is that the fields are returned in a randon order to the server. I don't know why is does this.

I'm passing back id/value to a database, so once I've written back to the Db i can use a sort order on ID to report in the correct order.

Regards

Andy G





Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms Collection can't find form Loralee Access 3 December 28th, 2006 12:17 PM
How to get the collection of forms ramesh_cnj .NET Framework 1.x 0 February 27th, 2006 08:47 AM
Collection in C# ? dedex C# 1 January 14th, 2005 04:51 PM
COM Collection ben0027 Visual C++ 0 May 1st, 2004 05:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.