hi,
i need to display a number of marketing questions from the database. The number can change, but let's say it's 3 at the moment. The questions can be yes/no or "wh", so depending on the sort i need either a text field or a radio button. So far so good.
The problem comes when i try to retrieve the info in these fields. I want to put them in an array, and then loop through it, but i haven't been succeeding.
Here's the code of the form with the fields: (qMQ is the query)
<table width="90%">
<cfoutput query="qMQ" maxrows="3">
<tr>
<Td><input type="Hidden" name="QuestionID#qMQ.Curre
ntRow#" value="#qMQ.int_MarketingQ
uestionid#
">
#qMQ.vch_MarketingQuestion
#
</td>
<td>
<cfswitch expression="#tnt_Marketing
QuestionTy
pe#">
<cfcase value="1">
<input type="Text" size="30" maxlength="200" name="Answers#qMQ.CurrentR
ow#">
</cfcase>
<cfcase value="2">
Yes <input type="Radio" name="Answers#qMQ.CurrentR
ow#" value="Yes" checked>
No <input type="Radio" name="Answers#qMQ.CurrentR
ow#" value="No">
</cfcase>
</cfswitch>
</td>
</tr>
</cfoutput>
<tr>
<td>
<br>
<input type="Submit" value="Save my answers">
</td>
</tr>
</table>
I've tried to define Answers as an array, and then define another array in the file it gets submitted to, but that didn't work either. What i'd like to have is something like:
<cfloop from="firstformfield" to="maxrows">
<cfstoredproc datasource="#Application.D
SName#" procedure="sp_AddMarketing
Answer" returncode="No">
<cfprocparam type="In" dbvarname="@QuestionId" value="#QuestionID[i]#" cfsqltype="CF_SQL_INTEGER"
>
<cfprocparam type="In" dbvarname="@Answer" value="#Form.Answers[i]#" cfsqltype="CF_SQL_VARCHAR"
>
<cfprocresult name="qMQ" resultset="1">
</cfstoredproc>
where [i] is the number of the element.
Is this possible, and if yes how? If not, what's the normal method?
thanks,
kandura
Start Free Trial