How to make ColdFusion checkboxes do partial post back write to SQL when clicked (OnClick)?

Posted on 2007-07-30
Medium Priority
Last Modified: 2009-12-16
I have an HTML table of several dozen recurring rows. In the 1st column of every row is a checkbox (fieldname="status", indicating Active or Inactive record).

When the user clicks that checkbox, I want to immediately (OnClick) send data to a ColdFusion action page (probably via hidden iFrame) to update the SQL database with the new status of that particular checkbox (now CHECKED or UNCHECKED). i.e., partial post back.

in other words, I don't want the user to have to check lots of checkboxes, then click a single Submit button to post them all en masse.

i think this guy has the right idea somehow, but i couldn't make his examples work: http://answers.google.com/answers/threadview?id=391498

I don't know javascript, except how to cut / paste it into HTML, but I can do any CF code work needed.
Running CF7 with IIS6 / Win2k3SvrStdSP1

thanks much!

Question by:OceanReefClub
1 Comment
LVL 14

Accepted Solution

Scott Bennett earned 500 total points
ID: 19595684
The last solution on that thread you posted a link to should work. Just set up a page like this:

<script language="JavaScript">
function UpdateDatabase(TheKey, TheStatus) {
      var URL = "http://www.yoursite.com/cgi-bin/actionpage.cfm?key=" + TheKey + "&value=" + TheStatus;
      parent.db_frame.location.href = URL;


<form name="form1" method="post" action="">
  <p><input name="key1" type="checkbox" id="key1" value="checkbox"
onClick="UpdateDatabase(this.name, this.status)"></p>
  <p><input name="key2" type="checkbox" id="key2" value="checkbox"
onClick="UpdateDatabase(this.name, this.status)"></p>
  <p><input name="key3" type="checkbox" id="key3" value="checkbox"
onClick="UpdateDatabase(this.name, this.status)"></p>
  <p><input name="key4" type="checkbox" id="key4" value="checkbox"
onClick="UpdateDatabase(this.name, this.status)"></p>
  <p><input name="key5" type="checkbox" id="key5" value="checkbox"
onClick="UpdateDatabase(this.name, this.status)"></p>

<iframe id="db_frame" name="db_frame" src="javascript:" scrolling="no"
border="0" style="margin:0;padding:0;position:absolute;visibility:hidden;z-index:98;background-color:#ffffff;border:0
 none #ffffff;overflow:hidden;"></iframe>

Then on your "actionpage.cfm" (or whatever you call it), you will set it up to look for the Key and Value url parameters the Value parameter will return True or False depending on whether or not he box is checked or unchecked. and the key parameter will return the name of the check box.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question