Hi Paul,
Thanks so much, as that fixed the issue, but can I ask:
would you still use cfif IsDefined? when you have a cfparam?

I asked a while back on this list,and was helped by somebody, who  
said that the proper way to check a checkbox should be done cfif  
isDefined.
I am curious, as I want to learn, and not just get code working,
thanks so much
John

On Jun 18, 2008, at 4:14 PM, Paul Kukiel wrote:

> 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:3767
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