You can also use <cfparams to put default values and check for default
values for all of your form fields.. e.g.

<cfparam name="form.name" default="" />
<cfparam name="form.age" default="0" />

<cfif form.age eq 0>
   <!--- the user failed to enter an age --->
</cfif>

<cfif not len(form.name)>
    <!--- no name entered, do not proceed --->
</cfif>

This way the form fields will always be there, even if they aren't populated.



On Wed, Mar 30, 2011 at 8:41 PM, Bobby Hartsfield <[email protected]> wrote:
>
> "CF throws up" doesn't tell us much but I'd imagine it isn't CF at all. I'd
> say it is more than likely the database server generating the error.
>
> CFqueryparam will solve this... among other things.
>
> All of those values should be using it.
>
> .:.:.:.:.:.:.:.:.:.:.:.:.:.
> Bobby Hartsfield
> http://acoderslife.com
> http://cf4em.com
>
>
> -----Original Message-----
> From: Scott Williams [mailto:[email protected]]
> Sent: Wednesday, March 30, 2011 9:10 PM
> To: cf-talk
> Subject: Processing Empty Form Fields
>
>
> Hi all --
>
> I have an edit record form that populates the fields with values from a
> database. The user can make changes to the information, click the Submit
> button,
> and the database is updated.
>
> Here's the code for the Update query:
>
> <cfquery name="query1" datasource="#dsn#">
> UPDATE Accounts
> Set Name='#form.Name#', PlanYearStartDate='#form.PlanYearStartDate#',
> ContactFName='#form.ContactFName#', ContactLName='#form.ContactLName#',
> ContacteMail='#form.ContacteMail#', ContactPhone='#form.ContactPhone#',
> eMailDayOfMonth=#form.eMailDayOfMonth#, eMailFrequency=#form.eMailFrequency#
> WHERE GroupNo='#form.GroupNo#';
> </cfquery>
>
> It works fine as long as there is data in every form field. If a form field
> is
> blank, however, CF throws up. For example, if I deleted the ContactPhone,
> eMailDayofMonth, and eMailFrequency data in the form fields, I get an error
> message with the following SQL:
>
> UPDATE  Accounts Set Name='GroupName', PlanYearStartDate='01-Jan-11',
> ContactFName='FName', ContactLName='LName',  ContacteMail='[email protected]',
>
> ContactPhone='', eMailDayOfMonth=,  eMailFrequency= WHERE GroupNo='A5432';
>
> How should I handle this?
>
> Scott
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:343438
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to