We help IT Professionals succeed at work.
Get Started

Checkbox will not stay checked on edit page

Eric Bourland
Last Modified: 2012-06-27
ColdFusion 9
MS SQL Server 2005

I feel like I am missing something obvious. I've built a simple form that creates / updates a database record.

The edit page contains a checkbox: Archive.

When I update a record and check the Archive checkbox, the database table is updated; column "Archive" is set to "True" for the edited record. That works as expected.

When I view the record again, the checkbox is unchecked. However the column "Archive" in the data table is still, of course, set to True.

I am following good, working examples set for me previously by _agx_, gdemaria, and others who have helped me with my numerous ColdFusion form questions.

What am I missing? Why does the Archive checkbox display as unchecked on the edit page, when its value is "True" in the Archive data column?

Thank you as always for any advice.


<cfif isDefined('form.Archive')>
<!--- checkbox has been checked and is present in post data --->
<cfset form.Archive = 1>
<cfset form.Archive = 0>
<!--- checkbox not checked and not present --->

<cfquery datasource="#application.datasource#" name="qry_editPage">
SELECT projectID
FROM whwtProjects
WHERE projectID = <cfqueryparam value="#val(url.projectID)#" cfsqltype="cf_sql_integer">

<strong>Archive Project:</strong> <cfinput type="checkbox" name="Archive" value="1" checked="#Archive eq 1#" />

Open in new window

Watch Question
This problem has been solved!
Unlock 5 Answers and 23 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