title: Update SQL with checkbox values
body: <p>I can display checkbox states from a SQL query, but I can't update them. I'm using bit as the data type. I'm pretty sure the problem is in the way I'm using cfif to test the values of the checkboxes. If I comment them out, any values I have in the table get overwritten by the cfparam defaults, and I get my little confirmation message on the action page.  I've tried cfif, cfif isDefined, etc. I've been reading and working on this since last week, just can't seem to wrap my head around it. Here's the sample code from my test server: (fyi I'm using the same action page to view and update the record.)</p>
  
  <pre><code>&lt;cfif isDefined ("form.update")&gt;
  
  &lt;cfparam name="checkbox1" default=0&gt;
  &lt;cfparam name="checkbox2" default=0&gt;
  &lt;cfparam name="checkbox3" default=0&gt;
  &lt;cfparam name="checkbox4" default=0&gt;
  
  
  &lt;cfif #form.chkbox1# EQ checked&gt;
  &lt;cfset checkbox1=1&gt;
  &lt;/cfif&gt;
  
  &lt;cfif IsDefined (form.chkbox2)&gt;
  &lt;cfset checkbox2=1&gt;
  &lt;/cfif&gt;
  
  &lt;!--- &lt;cfif IsDefined (form.chkbox3)&gt;
  &lt;cfset checkbox3=1&gt;
  &lt;/cfif&gt;
  
  &lt;cfif IsDefined (form.chkbox4)&gt;
  &lt;cfset checkbox4=1&gt;
  &lt;/cfif&gt; ---&gt;
  
  &lt;cfquery name="update" datasource="HHSCIntra"&gt;
  
      UPDATE tbl_checkbox
      SET chkbox1 = #checkbox1#, chkbox2=#checkbox2#, chkbox3=#checkbox3#, chkbox4=#checkbox4#
      WHERE RecID = #user#
  
  &lt;/cfquery&gt;
  
  &lt;cfoutput&gt;Record number: #user# Updated.&lt;/cfoutput&gt;
  
  &lt;cfelse&gt;
  
  &lt;cfquery name="checkboxview" datasource="HHSCIntra"&gt;
  
      SELECT * FROM tbl_checkbox WHERE RecID = #form.nameselect#
  
  &lt;/cfquery&gt;
  
  &lt;cfif #checkboxview.chkbox1# EQ 1&gt;
  &lt;cfset chkbox1checked="yes"&gt;
  &lt;cfelse&gt;
  &lt;cfset chkbox1checked="no"&gt;
  &lt;/cfif&gt;
  
  &lt;cfif #checkboxview.chkbox2# EQ 1&gt;
  &lt;cfset chkbox2checked="yes"&gt;
  &lt;cfelse&gt;
  &lt;cfset chkbox2checked="no"&gt;
  &lt;/cfif&gt;
  
  &lt;cfif #checkboxview.chkbox3# EQ 1&gt;
  &lt;cfset chkbox3checked="yes"&gt;
  &lt;cfelse&gt;
  &lt;cfset chkbox3checked="no"&gt;
  &lt;/cfif&gt;
  
  &lt;cfif #checkboxview.chkbox4# EQ 1&gt;
  &lt;cfset chkbox4checked="yes"&gt;
  &lt;cfelse&gt;
  &lt;cfset chkbox4checked="no"&gt;
  &lt;/cfif&gt;
  
  &lt;cfform action="checkboxaction.cfm" method="post"&gt;
  
  &lt;cfoutput query="checkboxview"&gt;#name#&lt;/cfoutput&gt;
  
  &lt;cfinput name="user" type="hidden" value="#checkboxview.RecID#"&gt;&lt;br&gt;
  
  
          Checkbox 1: &lt;cfinput type="checkbox" name="chkbox1" checked="#chkbox1checked#" value=1&gt;&lt;br&gt;
          Checkbox 2: &lt;cfinput type="checkbox" name="chkbox2" checked="#chkbox2checked#" value=1&gt;&lt;br&gt;
          Checkbox 3: &lt;cfinput type="checkbox" name="chkbox3" checked="#chkbox3checked#" value=1&gt;&lt;br&gt;
          Checkbox 4: &lt;cfinput type="checkbox" name="chkbox4" checked="#chkbox4checked#" value=1&gt;&lt;br&gt;
  
  &lt;br&gt;
  
  &lt;cfinput type="submit" name="update" value="Update"&gt;
  
  &lt;/cfform&gt;
  
  &lt;/cfif&gt;
  </code></pre>
  
  <p>Mahalo</p>