Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web Survey - Map specific form fields to a generic table field

Status
Not open for further replies.

jmgibson

Technical User
Oct 1, 2002
81
US
Hi.....I've created an online survey tool that presents several questions at once on a page and allows the user to select a single answer for each question. Once submitted, the field values (q1, q2, q3, etc) are submitted to the next page (what I call the action page) as follows:

Q1 = 100
Q2 = 200
Q3 = 400

What I would like to do is to capture in a table not only the field values, but also the field name. For instance, the table would like the following:

QuestionNumber | QuestionValue
Q1 100
Q2 200
Q3 300

Normally, the fieldname in my CF form would map to a fieldname in a table; however, I do not want to have matching tablefields for each question (since their are over 100 questions).

Anyone have any thoughts?
 
You can loop through the form collection to insert the name value pairs, for example:
Code:
<cfloop collection="#form#" item="fieldName">

    <cfquery name="qryInsert" ....... >
         INSERT INTO TAble
         ( fieldName, fieldValue)
         VALUES
         ('#fieldName#','#form[fieldName]#')
    </cfquery>
</cfloop>

Hope this helps,

JAlpino
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top