We help IT Professionals succeed at work.
Get Started

Passing unchecked checkbox value to an Action page

manuel2002m
manuel2002m asked
on
411 Views
Last Modified: 2013-12-24
I'm trying to pass the "NO" value from a checkbox to an Action page. If I pass the "yes" value everything works, but if I leave the checkbox unchecked I get the error "variable ACTIVE in undefined (I thought when you leave the checkbox empty it gets the value NULL or "0" ). Sorry, Im a newbie on CF, so my question is maybe silly. By the way, Im converting the "yes/no" from the checkbox to a "1/0" because Im using MS SQL on my DB. Thanks so much for the help. A friend of mine advised me to check first if the variable ACTIVE exist because the unchecked checkbox doesnt create the variable, but don't know how to do that.
The code on the Action Page looks like:

<cfif #active# is "yes" >
<cfset #active# = "1" >
<cfquery name="Categories" datasource="#DS1#">
INSERT INTO Categories (Description, Active)
VALUES ('#FORM.Description#',  '#Active#' )
</cfquery>
<cfoutput>You just inserted one record and #active#</cfoutput>
<cfelse>
<cfset #active# = "0" >
<cfquery name="Categories" datasource="#DS1#">
INSERT INTO Categories (Description, Active)
VALUES ('#FORM.Description#',  '#Active#' )
</cfquery>
<cfoutput>You just inserted one record and #active#</cfoutput>

</cfif>
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 2 Answers and 6 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE