<input type="hidden" name="c1" value="0">
        <input type="checkbox" name="c1" value="a">
        <input type="checkbox" name="c1" value="b">

-----Original Message-----
From: Daniel Kessler [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 01, 2005 12:50 PM
To: CF-Talk
Subject: inserting checkboxes into a db


I have a single file that's supposed to enter form data from several
pages into a database.  It checks to see if a form exists and if it
does, then it enters it's value into the database.
The problem that I'm running into is that when checkboxes aren't
checked, they don't exist with structKeyExists(form,'the_checkbox').
If I'm on a page that has a checkbox and it's not checked, I want to
set the value to 0, but if I'm on a form without any checkboxes, I
want to leave the value in the database alone.  I'm trying to use
this UPDATE page for the several pages that make up a section because
I'd rather not make a UPDATE page for each screen.

Here's the code that's not working:

<CFQUERY NAME="makeEdit" DATASOURCE="dpch">
      UPDATE empower_project_data
      SET
      <cfif structKeyExists(form,'politics')>
           <cfset session.politics = form.politics>
           politics = <cfqueryparam value="#session.politics#"
cfsqltype="CF_SQL_NUMERIC">,
      </cfif>
      <cfif structKeyExists(form,'demand')>
           <cfset session.demand = form.demand>
           form.demand:#form.demand#
           <cfabort>
           demand = <cfqueryparam value="#session.demand#"
cfsqltype="CF_SQL_NUMERIC">,
      </cfif>
      <cfif structKeyExists(form,'continuation')>
           <cfset session.continuation = form.continuation>
           continuation = <cfqueryparam value="#session.continuation#"
cfsqltype="CF_SQL_NUMERIC">,
      </cfif>
      date_modified = SYSDATE
      WHERE project_data_id = #session.project_data_id#
</CFQUERY>

--
Daniel Kessler

Department of Public and Community Health
University of Maryland
Suite 2387 Valley Drive
College Park, MD  20742-2611
301-405-2545 Phone
www.phi.umd.edu



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:208238
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to