Hi John,

Put this at the top of the results_page.cfm presuming no option checked
means no.

<cfparam name="form.tips" default="no" />
<cfparam name="form.health" default="no" />

Paul.

-----Original Message-----
From: John Barrett [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 19 June 2008 12:00 PM
To: CF-Newbie
Subject: checkboxes and INSERT

I am having an issue with writing a checkbox to my database. The code works
fine with POST, but when I try to add it to a cfquery, I get an issue(I
think) with "cfif IsDefined". I wanted a situation that if the checkbox was
not checked to have an error message. All works fine when I comment out the
cfquery,and just post the data, but if the checkbox is not checked, I get an
error that it is not defined in form. Why would this form break by writing
it to a db?

Thanks so much for any help,
John
/----------form_page.cfm------------------/
<cfform action="results_page.cfm" method="post">

<b>Are you interested in Today's Senior tips e-mailed to you?</b><br>
<table width="391">
  <tr>
    <td width="113"><cfinput type="checkbox" name="tips" value="yes">
    yes</td>
    <td width="134"><cfinput type="checkbox" name="tips" value="no">
    no </td>
   
  </tr>
</table>

<b>Are you interested in recieving other health information for seniors
e-mailed to you?</b><table width="391">
  <tr>
    <td width="113"><cfinput type="checkbox" name="health" value="yes">
    yes</td>
    <td width="134"><cfinput type="checkbox" name="health" value="no">
    no </td>
  </tr>
</table>
<!--- submit button --->
<cfinput type="Submit" name="SubmitForm" value="Submit">
<!--- Reset button. --->
<cfinput type="Reset" name="ResetForm" value="Clear">
</cfform>
/----------action_page.cfm------------------/
<cfoutput>
  
   <!--- If any mail alerts were checked, output them --->
  <cfif IsDefined('form.tips')>
    <b>Tips was chosen?</b> #tips#<br>
  <cfelse>
    <b>Tips were chosen:</b> No Tips were selected<br>
  </cfif>

  <!--- If any mail alerts were checked, output them --->
  <cfif IsDefined('form.health')>
    <b>topics:</b> #health#<br>
  <cfelse>
    <b>health was chosen?</b> No health products were selected<br>
  </cfif>

<!--- Insert checkbox data into DB--->
<cfquery datasource="MYDSN">
INSERT INTO tip(tips, health)
VALUES ('#FORM.tips#', '#FORM.health#')
</cfquery>




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

Archive: 
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3766
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to