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

Posted on 2007-07-30
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:

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

    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 = "" + 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.status)"></p>
      <p><input name="key2" type="checkbox" id="key2" value="checkbox"
    onClick="UpdateDatabase(, this.status)"></p>
      <p><input name="key3" type="checkbox" id="key3" value="checkbox"
    onClick="UpdateDatabase(, this.status)"></p>
      <p><input name="key4" type="checkbox" id="key4" value="checkbox"
    onClick="UpdateDatabase(, this.status)"></p>
      <p><input name="key5" type="checkbox" id="key5" value="checkbox"
    onClick="UpdateDatabase(, 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

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
    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…
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now