Generally it is. With radio buttons and checkboxes you'll probably find it
isn't.

However, it's generally considered good practice to cfparam all of the form
variables.



-----Original Message-----
From: Tim Laureska [mailto:[EMAIL PROTECTED]
Sent: Friday, 17 October 2003 12:03 p.m.
To: CF-Talk
Subject: RE: passing empty form field entry

Thanks Matthew... so if a form field entry is left blank, the variable
is not passed to the receiving template?

-----Original Message-----
From: Matthew Walker [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 16, 2003 7:54 PM
To: CF-Talk
Subject: RE: passing empty form field entry

Basically cfparam is a way of saying "let's just make sure this variable
exists as we're relying on it." You can also also do other things with
it
but that's the basic deal.

Here's a custom tag I knocked together this morning which is similar to
cfparam but a bit more featureful. You call it  like this:

<cf_param name="attributes.chunksize" type="numeric" default="10"
min="1"
max="100">

Instead of throwing an error it simply fixes up the data. It's not very
tested but feel free to play. There're probably better versions around.

<cfparam name="attributes.name" type="string">

<cfparam name="attributes.type" type="string" default="">

<cfparam name="attributes.min" default="">

<cfparam name="attributes.max" default="">

<cfif structkeyexists(caller, attributes.name)>

            <cfset value = caller[attributes.name]>

<cfelseif structkeyexists(attributes, "default")>

            <cfset value = attributes.default>

<cfelse>            

            <cfset value = "">

</cfif>

<cfif attributes.type eq "numeric">

            <cfset value = val(value)>

</cfif>

<cfparam name="value" type="#attributes.type#">

<cfif attributes.type eq "numeric">

            <cfif len(attributes.min)>

                        <cfif value lt attributes.min>

                                    <cfset value = attributes.min>

                        </cfif>

            </cfif>

            <cfif len(attributes.max)>

                        <cfif value gt attributes.max>

                                    <cfset value = attributes.max>

                        </cfif>

            </cfif>

                        

</cfif>

<cfset caller[attributes.name] = value>



-----Original Message-----
From: Tim Laureska [mailto:[EMAIL PROTECTED]
Sent: Friday, 17 October 2003 11:49 a.m.
To: CF-Talk
Subject: RE: passing empty form field entry

Where do you set the cfparam?  In the receiving template such as
<cfparam name="exp_months" default="">

I've always struggled with CFPARAM

-----Original Message-----
From: Matthew Walker [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 16, 2003 7:36 PM
To: CF-Talk
Subject: RE: passing empty form field entry

The standard way is a cfparam.

-----Original Message-----
From: Tim Laureska [mailto:[EMAIL PROTECTED]
Sent: Friday, 17 October 2003 11:21 a.m.
To: CF-Talk
Subject: passing empty form field entry

If a web site visitor completes a form without entering data in a field
(which in this case may be OK), how do you set up the coding for
inserting that "blank" entry into a database (or ignoring that field).  

If I include the field in the SQL insert statement, I get an error
"resolving parameter"

I'm trying to avoid a bunch of CFIF statements (ie. CFIF "field EQ '',
then such and such CFELSE such and such)

TIA
Tim

  _____  

  _____  


  _____  


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to