I'm trying to insert the value of selected radio buttons using CFLOOP
and #form.fieldNames#.
It's returning the correct values that need to be inserted into the
database, but it's also returning the value and name of my submit
button.
I thought using form.fieldNames was correct but I'm not sure how to
return all the selected fields but not the submit? Thanks for any help!


<!--- // FORM --->
<cfform action="page.cfm" method="get">
<table>
<cfoutput query="getAll" group="statusName">
        <tr>
                <th class="rowStatusId" colspan="3">#statusName#</th>
         </tr>
         <cfoutput>
        <tr class="#iif(currentrow MOD
2,DE('rowAltOne'),DE('rowAltTwo'))#">
                <td align="center"><input type="radio" name="#dbId#"
value="7" /></td>
                <td align="center"><input type="radio" name="#dbId#"
value="8" /></td> 
                <td>#dbNameFirst# #dbNameLast#</td>
        </tr>
        </cfoutput>
</cfoutput>
</table>
<p><input name="inputButton" class="formButton" type="submit"
value="submit" /></p>
</cfform>

<!--- // LOOPING and INSERT --->
<cfif isDefined("form.inputButton")>
<cfloop index="i" list="#form.fieldNames#">     
        <!--- test output to make sure it's giving correct values --->
        <cfoutput>
        #i# <br /> 
        #form[i]# <br /><br /> 
        </cfoutput>
<!--- insert that bombs because of the text --->
<cfquery datasource="#dbname#" name="addContact">
                INSERT INTO contact
                FIELDS (contactDbId,contactTypeId,contactDate)
                VALUES (#Evaluate(i)#,#form[i]#,#DateFormat(Now(),
'yyyy-mm-dd')#)
        </cfquery>
</cfloop>
<cfelse> .......

Give me this:

361 <---- dbId (correct)
8 <----- contactTypeId (correct) 

807 <---- dbId (correct)
7 <----- contactyTypeId (correct)

INPUTBUTTON <----- how do I not output this?
submit  <------- and this?

<!--- // ERROR --->

Syntax error or access violation message from server: "You have an error
in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near &apos;FIELDS
(contactDbId,contactTypeId,contactDate) VALUES (448,8,2008-01-05)&apos;
at line 2"  
  

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:295953
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to