default value for form data

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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: ...
  3. #2

    Default 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

  4. #3

    Default 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

  5. #4

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139