I have two lists and
a text area on a form page. The lists are tables with
checkboxes. On the action page, the first list processes fine, however,
the second does not (I haven't gotten to checking the text area yet). Here
is the form:
<html>
<head>
<title>Page 7</title>
</head>
<head>
<title>Page 7</title>
</head>
<body>
<form name="TargetGroups" action="ProcessPage7.cfm" method="post">
<table cellspacing="0" cellpadding="0" ><tr><td align="justify" ><font color="Navy" ><b>
<form name="TargetGroups" action="ProcessPage7.cfm" method="post">
<table cellspacing="0" cellpadding="0" ><tr><td align="justify" ><font color="Navy" ><b>
B. Target Groups --
Indicate with a check mark the target groups that received project services
during the 2000 - 2001 SDFS Project
period.</b></font>
</td></tr></table><br>
</td></tr></table><br>
<cfoutput
query="qryTargetGroup">
<table border="1"><tr><td>
<!--- <input type="Hidden" name="DistrictId" value="#session.DistrictID#"> --->
<td><input type="Checkbox" value="#Groupnumber#" name="Groupnumber"></td>
</td><td><font size="-1" style="TimesNewRoman"> #groupname#</font></td></tr></table>
<table border="1"><tr><td>
<!--- <input type="Hidden" name="DistrictId" value="#session.DistrictID#"> --->
<td><input type="Checkbox" value="#Groupnumber#" name="Groupnumber"></td>
</td><td><font size="-1" style="TimesNewRoman"> #groupname#</font></td></tr></table>
</cfoutput>
<br><br>
<br><br>
<b><font
color="Navy">
C. District/School
Policies/Practices</font></b><br><font
color="Navy">
1. In the chart
below, place a check mark in the boxes that reflect the ATOD use and violence
prevention policies enforced in your district, or in some schools in your
district. Indicate whether the policy is a district policy or a school
option. (Note: The district Safe Schools Survey responses should provide
information on many of these.)</font>
<table
border="1"><tr><th>District Policy</th><th>School
Option</th></tr><tr>
<cfoutput query="qryPolicy">
<!--- <td><input type="hidden" value="#Policynumber#" name="Policynumber"></td> --->
<td><input type="checkbox" value="Yes" name="d_#policynumber#"> </td>
<td><input type="Checkbox" value="Yes" name="s_#policynumber#"> </td>
<td><font size="-1" style="TimesNewRoman"> #Policyname#</font></td></tr>
<cfoutput query="qryPolicy">
<!--- <td><input type="hidden" value="#Policynumber#" name="Policynumber"></td> --->
<td><input type="checkbox" value="Yes" name="d_#policynumber#"> </td>
<td><input type="Checkbox" value="Yes" name="s_#policynumber#"> </td>
<td><font size="-1" style="TimesNewRoman"> #Policyname#</font></td></tr>
</cfoutput>
</table><br><br>
<table>
<tr><td><font color="navy">
</table><br><br>
<table>
<tr><td><font color="navy">
C. 2. List the "Hot
Topics" offered in the district through the 2000-2001 SDFS Project. (Use this
format: Hot Topic1, Hot Topic2, Hot Topic3, etc.) When you are finished typing
in the information click SUBMIT at the
end.
</font></td></tr>
</font></td></tr>
<cfoutput query="qryHotTopics">
<tr><td><textarea NAME="HotTopic" ROWS="10" COLS="40" Wrap="virtual">#HotTopic#
</textarea></td></tr>
</table>
</cfoutput>
<input type="Submit"
value="SUBMIT">
</form>
</form>
</body>
</html>
Here is the processing page:
<cfif
isdefined("GroupNumber")>
<cfloop list="#GroupNumber#" index="x">
<cfquery datasource="#application.db#">
Insert into tlnkTargetGroups (DistrictID, GroupNumber)
Values ('#session.DistrictID#', #x#)
<cfloop list="#GroupNumber#" index="x">
<cfquery datasource="#application.db#">
Insert into tlnkTargetGroups (DistrictID, GroupNumber)
Values ('#session.DistrictID#', #x#)
</cfquery>
</cfloop>
</cfif>
</cfif>
<cfif
isdefined("form.fieldnames")>
<cfloop list="#form.fieldnames#" index="i">
<cfset PolicyNumber = right(i, len(i) - 2)>
<cfif left(i, 1) IS "d">
<cfset district = 1>
<cfelse>
<cfset district = 0>
</cfif>
<cfif left(i, 1) IS "s">
<cfset School = 1>
<cfelse>
<cfset School = 0>
</cfif>
<cfloop list="#form.fieldnames#" index="i">
<cfset PolicyNumber = right(i, len(i) - 2)>
<cfif left(i, 1) IS "d">
<cfset district = 1>
<cfelse>
<cfset district = 0>
</cfif>
<cfif left(i, 1) IS "s">
<cfset School = 1>
<cfelse>
<cfset School = 0>
</cfif>
<!---
<cfoutput>#session.DistrictID# #right(i, len(i) - 2)# #district#
#School#</cfoutput><br> --->
<cfquery
datasource="#application.db#">
Insert into tlnkPolicy (DistrictID, District, school, PolicyNumber)
Values ('#session.DistrictID#', '#District#', '#School#', #PolicyNumber#)
</cfquery>
Insert into tlnkPolicy (DistrictID, District, school, PolicyNumber)
Values ('#session.DistrictID#', '#District#', '#School#', #PolicyNumber#)
</cfquery>
<!--- </cfif> --->
</cfloop>
<cfif
isdefined("form.HotTopics")
<cfupdate datasource="#Application.db#" tablename="tblDistrictInfo" dbtype="ODBC"
formfields="DistrictID, HotTopic">
</cfif>
<cfupdate datasource="#Application.db#" tablename="tblDistrictInfo" dbtype="ODBC"
formfields="DistrictID, HotTopic">
</cfif>
The first <cfloop
list="#GroupNumber#" index="i"> processes fine. The second one
<cfloop list="#Form.FieldNames#" index="i"> does not. I haven't even
gotten to processing the text area yet. I think the processing is breaking
down because of the list="#Form.fieldnames#". It loops through all the
fieldnames on the form not just the second group. I am sure this is true
because if I do not put any checkmarks in the first group it processes
fine. I feel I have tried every combination of list=(something) and I
can't seem to come up with the solution. When I try the above code and put
checkmarks in both groups, I get the following error:
Error Diagnostic Information
ODBC Error Code = 07001 (Wrong number of parameters)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
Hint: The cause of this error is usually that your query contains a reference to a field which does not exist. You should verify that the fields included in your query exist and that you have specified their names correctly.
SQL = "Insert into tlnkPolicy (DistrictID, District, school, PolicyNumber) Values ('xMe', '0', '0', OUPNUMBER)"
Data Source = "SDFS"
The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (62:1) to (62:39) in the template file C:\Inetpub\ccDir\WebPage2001\ProcessPage7.cfm.
