Solved

Enumerating Form Field Values

Posted on 2004-04-12
6
817 Views
Last Modified: 2008-03-10
I have a form in an asp page and I want to transfer the form values to another asp page which I can do by submitting the form to eg page2.asp. Inside page2.asp I believe I can return specific field values using:

Request.form("fieldname")

However because the field names were written dynamicly, I don't know the field names; how can I loop through the fields collection checking for certain field types.
0
Comment
Question by:ncw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 30

Expert Comment

by:third
ID: 10804221
<h3> Form Collection </h3>
<%
For Each Item in Request.Form
  For iCount = 1 to Request.Form(Item).Count
    Response.Write Item & " = " & Request.Form(Item)(iCount) & "<br>"
  Next
Next

for each qryItem in Request.Form
 strMsgInfo = strMsgInfo &  qryItem & " :: " & request.Form(qryItem) + vbNewLine + vbNewLine
next

Response.Write strMsgInfo
%>
0
 
LVL 30

Expert Comment

by:third
ID: 10804243
btw, here's the entire ASP objects collection,

http://www.4guysfromrolla.com/webtech/021099-1.shtml
0
 
LVL 1

Author Comment

by:ncw
ID: 10804704
From this I seem to be able to return the name and value of all input fields; how can I return the id value? The reason is that the form has items for selection by checkboxes and the checkboxes take the name of the associated item with the checkbox value set to the item value, but there are other hidden text fields too which I know the names of? I just want to enumerate the fields of type checkbox or fields with an id of eg "chk".

The object collection debug page was good, thanks.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Accepted Solution

by:
Sleepyhead_NO earned 250 total points
ID: 10805315
you can't return the id value - it is for client side scripting only. When the form is posted only the request name and value is posted to the action page.

If you only want to list thos form elements with name = "chk" then do this:

dim form_item
for each form_item in request.form
     if form_item = "chk" Then
           response.write form_item & " = " & request.form(form_item).value & "<br>" & vbNewLine
     end if
next
0
 
LVL 1

Author Comment

by:ncw
ID: 10806467
In my page I use asp to write a list of options which have different descriptions and different prices, and against each I have a checkbox. What  I was hoping was to set the name of each checkbox to the description of the option and set the value to the option price and then, in the asp page the form is submitted to, enumerate the names and values of all checked checkboxes. I could do that if only the checkboxes were submitted but I am also submitting values in hidden fields.

I guess I could preceed each checkbox name with 'chk_' and then check the first 4 letters of each item name for 'chk_'. Can you see a better way?
 
0
 
LVL 30

Expert Comment

by:third
ID: 10809735
"I guess I could preceed each checkbox name with 'chk_' and then check the first 4 letters of each item name for 'chk_'."

yup. this is a good idea but the better way i'm thinking is, you assign common name to each of your checkboxes and set the value of the checkbox to description+delimeter+price format (i.e. <input type="check" id="chk" name="chk" value="desc|1.00">). then on your action page, you can loop through the chk form array and split each value by the delimeter to get the description and price.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question