Ryan,
Ryan,

I ran into the same problem.  I was using CF_REUSEFORM, everything but the
checkboxes were being filled out.  I still use CF_REUSEFORM for the other
elements in the form but here's a basic example of how I handled check
boxes....  

First, I wrote a query to select the values for my checkboxes.  My checkbox
values are stored in a table CHOICES with a CHOICE_ID (number) and
CHOICE_NAME (text).  Boxes that are checked off are stored in USER_CHOICES,
which has the fields USER_ID and CHOICE_ID.  So, my query does an outer join
between CHOICES and a dynamic view of the current user choices.  If the
choice is in USER_CHOICES, the field chosen is set to Y, else it is sent to
N.  (My query is for ORACLE.  I believe DECODE maybe ORACLE-specific. So, if
you are using a different DB, it may have to be translated.)

The Cold Fusion code goes through the query, create a checkbox for each of
the choices.  If chosen is set to Y, it marks the box as selected.


The query: 

        select 
                c.choice_name
                , c.choice_id 
                ,decode(d.choice_id,null,'N','Y') chosen
        from 
                choices c
                ,(select 
                                * 
                        from 
                                user_choices 
                        where
                                user_id = '#attributes.user_id#'
                        )       u
        where
                c.choice_id = u.choice_id (+)
        order by 
                c.choice_id

The CF code:

                <cfoutput query="get_choices">
                        <input type="checkbox"
name="choice#get_choices.choice_id#_cb"
                                <cfif get_choices.chosen eq
"Y">checked</cfif>
                        > #get_choices.choice_name# <br>
                </cfoutput>

I hope that helps at least a little bit.  If you have any questions, feel
free to contact me.

Ralph

-----Original Message-----
From: Ryan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 01, 2000 5:22 PM
To: Fusebox
Subject: cf_reuseform and checkboxes


As I understand it, when you use CF_reuseform, you code your forms
like <input name=name value="#name#"> and then use cf_reuseform to
default the variables to blank if loading the form for the first time,
or set these variables to what was passed in on a form so you
can redisplay the form (with data filled in) if there were errors.

So how do you code checkboxes using reuseform? I didn't see anything
about it in the fusebox book nor in the txt file that came with the
custom tag. My guess would be:

<input type=checkbox name=has_bmw value=1 <CFIF has_bmw EQ 1>CHECKED</CFIF>>

or maybe even

<input type=checkbox name=has_bmw value=1 <CFIF
IsDefined(has_bmw)>CHECKED</CFIF>>

But, if you call cf_reuseform and pass it action="form"
formfields="name,has_bmw,etc",
and the user didn't check has_bmw the first time through, cf_reuseform
throws
an error because FORM.has_bmw does not exist!

What is one to do?

Ryan

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

Reply via email to