Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Enumerating Form Field Values

Posted on 2004-04-12
6
Medium Priority
?
829 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Accepted Solution

by:
Sleepyhead_NO earned 1000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

597 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