I can't quite get this to work.
My form has a number of inputs including one checkbox. In my cfquery
, I just want to write some simple SQL content that tests to see if the checkbox is checked or not. But my code just ignores it completely. Here's the basics:
<cfform name="form" action="...." format="HTML">
....
<cfinput type="checkbox" name="search_NR" id="search_NR" checked="no" />
<cfinput type="submit" name="submit" value="Search" />
</cfform>
My cfquery
is quite extensive, so I'll just put the part relevant to the checkbox here:
<cfif isDefined("form.search_NR")>
AND (tblMain.NR = true)
</cfif>
My thought was that the box wouldn't be defined if it wasn't checked. But whether or not I check the box on the form, the query just ignores this altogether. I just want to add tblMain.NR = TRUE
to the rest of the SQL content when the box is checked.
<cfif StructKeyExists(form, "search_NR")>
AND (tblMain.NR = true)
</cfif>