Skip to main content
June 29, 2009
Question

Checkbox

  • June 29, 2009
  • 2 replies
  • 588 views

I have a form with multiple checkboxes for insurance types. If one or more are checked the insert works properly. However, if none are checked, I get an error that the field is "undefined in form". My action page insert query is written "<CFQUERYPARAM CFSQLType="CF_SQL_Varchar" Value="#Form.VCTM_REIMBRS_TYPE#" Null="#Len(Form.VCTM_REIMBRS_TYPE) EQ 0#">" and the SQL field is checked to allow NULLS. What am I missing?

This topic has been closed for replies.

2 replies

Dileep_NR
Inspiring
June 30, 2009

Hi,

Check the Form.VCTM_REIMBRS_TYPE isdefined

<cfif isdefined("Form.VCTM_REIMBRS_TYPE") AND len(trim(Form.VCTM_REIMBRS_TYPE))>

...

</cfif>

Inspiring
June 29, 2009

For check boxes, if none are checked on the form, the form variable will not exist.  There are several ways to deal with this.  You must first, however, decide in plain english what you want to happen if nothing is checked.  Translating that decision to code is usually simple.