You can do the inserts and the updates inside a loop as well.

Possibly just append a count variable from 1 to the number of rows in your
query at the end of your variable.  For example,

<cfloop>
        boxes#count#
</cfloop>


This would make every variable different for your form and you can then use
another loop to access the form variables and insert or update via another
loop calling boxes#count#.  I messed with this for some time last week and
the syntax gets hairy but once you figure it out you can add questions just
by inserting them into your database and then the parameters can all be
changed via the query telling the <cfloop> tag how many times to loop.  So
you could have 1 question or 10,000 and it doesn't matter.  The loop will
take care of it all inserting the answers to the questions.

The list idea others have given sounds good as well.

Good luck!



Michael W. Blair

Web Applications Developer
Canyon WebWorks
An Arizona Internet LLC Company
http://www.canyon.net
[EMAIL PROTECTED]
PHONE: (520) 773-9059
FAX:   (520) 773-4945

-----Original Message-----
From: Judah McAuley [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 29, 2000 3:41 PM
To: [EMAIL PROTECTED]
Subject: Re: 237 checkboxes

If you name each of the checkboxes the same (all name="survey_answer" or
some such) and give each a different value (name="survey_answer"
value="votedinelection" name="survey_answer"
value="incomegreaterthan30000") then you would get a comma delimited list
of all the checked boxes coming through
(survey_answer=votedinelect,incomegreaterthan30000).  You could then loop
through this list and do updates.  If you gave the checkboxes values
identical to database fields and defaulted the values in the DB to 0 or NO,
then you could construct the loop fairly simply:

<cfquery>
*insert blank record*
</cfquery>

  <cfloop index="answer" list="#form.survey_answer#">
         <cfquery>
         UPDATE dbtable
         SET #answer# = 'YES'
         WHERE id = #id_from_previous_query#
         </cfquery>
</cfloop>

This will be easier to code than 237 ifs, but on the other hand it could
potentially involve 237 updates instead of just one Insert.
Efficiency will be determined by percentage of checkboxes likely to be
checked.

Hope this helps,
Judah

At 05:21 PM 3/29/00 -0500, you wrote:
>I have search form that contains a large amount of yes/no check boxes -237
>to be exact. It is to search the results of a survey that has 237
questions.
>
>Only when a checkbox is checked will data be sent from the form. Because of
>this I need to check if each variable is present. I can create 237 "CFIF
>IsDefined" statements to see if the variables are present. The other option
>is to set 237 CFPARAM variables to "NO" as default, and then create my
>dynamic SQL statements with CFIF tags checking for "YES".
>
>The problems with these two options is that they are slow and will take a
>long time to code.
>
>I was thinking:
>
>Is there a way to create a loop that will run through all the values from
>the form - creating a query and output for each one.
>
>Thanks, Dan
>---------------------------------------------------------------------------
---
>Archives: http://www.eGroups.com/list/cf-talk
>To Unsubscribe visit
>http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
>send a message to [EMAIL PROTECTED] with 'unsubscribe' in
>the body.

----------------------------------------------------------------------------
--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.

------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to