Ask a Question related to Coldfusion Database Access, Design and Development.
-
sdtke212 #1
default value for form data
Hello,
So, I'm working a on a an online survey and so far, everything is great. My
problem lies in that everything works great if a user enters a value for every
question on the form. But the user doesn't always have to enter a value, he can
leave whatever fields blank that he wants. I tried using <CFPARAM>, but it's
giving me this error.
the tag:
<cfparam name="form.dm01" default="0">
Error Executing Database Query.
Invalid data for CFSQLTYPE CF_SQL_NUMERIC.
I am using SQL Server 2000 and stored procedures. Here is what one of my
<CFPROCPARAM> looks like:
<cfprocparam type="in" cfsqltype="cf_sql_numeric" dbvarname="@var1"
value="#form.dm01#">
The fields in the database allow null values and I guess that is what ideally
I would want inserted into the database
if no value is entered. If I could have some input or feedback or guidance as
to where I am going wrong or what
direction I should, please let me know.
Thanks!
Ryan
sdtke212 Guest
-
Autopopulated form not displaying data in pdfunless the form field is clicked
Within my online application, I have a pdf form that is auto generated and displayed to the user in the browser. My problem is that the populated... -
Form validation - Textbox not default value
I've been using Yaromats excellent extension to validate my forms. Usually works great, but now I have a new requirement. Some of my forms... -
Passing default value from Form
I'm trying to pass a default value from a hidden tag on a form, but I'm not sure it's possible. Here's the scenario: I want to set a default... -
mx 7 flash form The form data has expired, Please reloadthis page in your browser.
When i first go to any flash form on my CFMX 7 server i get the following message. The form data has expired, Please reload this page in your... -
Set button as default on web form
In article <002b01c34a30$c63dcb50$a601280a@phx.gbl>, Michael.Rainey@pnl.gov says... Use "Page.RegisterHiddenField". See this newsgroup post: ... -
mxstu #2
Re: default value for form data
It depends on the type of form field you are using. If "form.dm01" is a
textbox, it will always exist on the action page and the CFPARAM will have no
effect.
Since you are using CF_SQL_NUMERIC, you could use the IsNumeric() function to
check the form field value. If the value is numeric then insert it, otherwise
insert NULL.
<cfif IsNumeric(form.dm01)>
<cfprocparam type="in" cfsqltype="cf_sql_numeric" dbvarname="@var1"
value="#form.dm01#">
<cfelse>
<cfprocparam type="in" cfsqltype="cf_sql_numeric" dbvarname="@var1"
value="#form.dm01#" null="yes">
</cfif>
You could simplify that code by putting the logic in a UDF (that returns
yes/no). So let's say your UDF was named "IsNumericNull", you could write
something like this....
<cfprocparam type="in" cfsqltype="cf_sql_numeric" dbvarname="@var1"
value="#form.dm01#" null="#IsNumericNull(form.dm01)#">
mxstu Guest
-
Dan Bracuk #3
Re: default value for form data
You have a data type mismatch. Take the quotes out of the default attribute of your cfparam tag.
Dan Bracuk Guest
-
mxstu #4
Re: default value for form data
Originally posted by: Dan Bracuk
You have a data type mismatch. Take the quotes out of the default attribute of your cfparam tag.
Since CF is loosely typed, that should not make a difference.
mxstu Guest



Reply With Quote

