RE: inserting checkboxes into a db

2005-06-02 Thread daniel kessler
this worked well.  thank you very much

No. Fields with the same name name return a comma-delimited list when more
than 1 is checked. Also, a checkbox is not True or False, it is Undefined or
Value (of value=#checkbox_value#).

In your case, the hidden field should be present on forms with checkboxes
and provide, as you surmised, a defualt value of 0.
Use IsDefined('FORM.checkbox_name') in the UPDATE to determine whether to
updaytre the field.


-Original Message-
From: daniel kessler [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 01, 2005 1:44 PM
To: CF-Talk
Subject: RE: inserting checkboxes into a db


input type=hidden name=c1 value=0
  input type=checkbox name=c1 value=a
  input type=checkbox name=c1 value=b

So the hidden sets the default value, right?  Here's what I did.

on the page:
input type=hidden name=#checkbox_name# value=0
input name=#checkbox_name# #checked# type=checkbox id=#checkbox_name#
value=#checkbox_value#

and on the UPDATE page, I left it as is:
cfif structKeyExists(form,'mandate')
 cfset session.mandate = form.mandate
mandate = cfqueryparam value=#session.mandate#
cfsqltype=CF_SQL_NUMERIC,
/cfif

So, whenever the checkbox exists, it'll either input this the checkbox value
or it's hidden field, because the checkbox won't overwrite it.  right?

oh, I just checked that and it sorta works.  If it's not checked, it works
fine.  If it's checked, then it puts out 38352 in the value, rather than the
1 it's supposed to be.  I suppose it's having problems with two fields being
named the same.

While I don't know if this is how you meant for me to implement it, it
seemed intriguing.

~|
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:208420
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=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: inserting checkboxes into a db

2005-06-01 Thread Dave Watts
 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.

You will have to have some way of tracking within your form data whether
there was originally a checkbox in the page. One easy way to do this is to
simply add a hidden form field within that page.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized 
instruction at our training centers in Washington DC, Atlanta, 
Chicago, Baltimore, Northern Virginia, or on-site at your location. 
Visit http://training.figleaf.com/ for more information!


~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:208237
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


RE: inserting checkboxes into a db

2005-06-01 Thread Dave Francis
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


RE: inserting checkboxes into a db

2005-06-01 Thread daniel kessler
You will have to have some way of tracking within your form data whether
there was originally a checkbox in the page. One easy way to do this is to
simply add a hidden form field within that page.

So, I guess the hidden field has to have a value that indicates the page, 
rather than just true and false.  Because if I have one page with checkboxes 
and it just sets the hidden field to true then it'd be true for other 
checkboxes on the update page.

~|
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:208240
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


RE: inserting checkboxes into a db

2005-06-01 Thread daniel kessler
input type=hidden name=c1 value=0
   input type=checkbox name=c1 value=a
   input type=checkbox name=c1 value=b

So the hidden sets the default value, right?  Here's what I did.

on the page:
input type=hidden name=#checkbox_name# value=0 
input name=#checkbox_name# #checked# type=checkbox id=#checkbox_name# 
value=#checkbox_value#

and on the UPDATE page, I left it as is:
cfif structKeyExists(form,'mandate')
 cfset session.mandate = form.mandate
mandate = cfqueryparam value=#session.mandate# cfsqltype=CF_SQL_NUMERIC,
/cfif

So, whenever the checkbox exists, it'll either input this the checkbox value or 
it's hidden field, because the checkbox won't overwrite it.  right?

oh, I just checked that and it sorta works.  If it's not checked, it works 
fine.  If it's checked, then it puts out 38352 in the value, rather than the 1 
it's supposed to be.  I suppose it's having problems with two fields being 
named the same.

While I don't know if this is how you meant for me to implement it, it seemed 
intriguing.

~|
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:208246
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


RE: inserting checkboxes into a db

2005-06-01 Thread Dave Francis
No. Fields with the same name name return a comma-delimited list when more
than 1 is checked. Also, a checkbox is not True or False, it is Undefined or
Value (of value=#checkbox_value#).

In your case, the hidden field should be present on forms with checkboxes
and provide, as you surmised, a defualt value of 0.
Use IsDefined('FORM.checkbox_name') in the UPDATE to determine whether to
updaytre the field.


-Original Message-
From: daniel kessler [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 01, 2005 1:44 PM
To: CF-Talk
Subject: RE: inserting checkboxes into a db


input type=hidden name=c1 value=0
   input type=checkbox name=c1 value=a
   input type=checkbox name=c1 value=b

So the hidden sets the default value, right?  Here's what I did.

on the page:
input type=hidden name=#checkbox_name# value=0
input name=#checkbox_name# #checked# type=checkbox id=#checkbox_name#
value=#checkbox_value#

and on the UPDATE page, I left it as is:
cfif structKeyExists(form,'mandate')
 cfset session.mandate = form.mandate
mandate = cfqueryparam value=#session.mandate#
cfsqltype=CF_SQL_NUMERIC,
/cfif

So, whenever the checkbox exists, it'll either input this the checkbox value
or it's hidden field, because the checkbox won't overwrite it.  right?

oh, I just checked that and it sorta works.  If it's not checked, it works
fine.  If it's checked, then it puts out 38352 in the value, rather than the
1 it's supposed to be.  I suppose it's having problems with two fields being
named the same.

While I don't know if this is how you meant for me to implement it, it
seemed intriguing.



~|
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:208248
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