Skip to main content
April 25, 2011
Question

Need checkbox onclick somehow to run SQL query

  • April 25, 2011
  • 1 reply
  • 1465 views

Hello all,

Now, I know directly I cannot do this with a javascript function.  What I need to do is with a checkbox onclick

set a hidden field to the type of the data that is selected by the checkbox.  So, if I select the name of a person,

the onclick method needs to let the hidden field know we have a "person" entity type. I need this type because

when I do my true submit, that form field when read will denote what next page I need to bring up in a new tab.

The question I have is ok, I can attempt to do this a couple of ways, following:

1)  Come up with an AJAX call that will run a function on the server.  What I do worry about is

submitting the page and ending up losing boxes that were checked.  I also don't want a long

form submittal after every click.

OR

2)  Forget the onclick method, create a blank .cfm form, then use that form to run the query for the

types of data, and then call the page to be displayed?  Again, I'm new, so I don't know if this could

be weird in how the page comes up for display?

Thanks in advance!!!!!

    This topic has been closed for replies.

    1 reply

    Inspiring
    April 26, 2011

    You appear to be complicating something simpler.  Why do you need a hidden field when you already have the checkbox?  Also, why not simply process the form after it's been submitted?

    April 26, 2011

    Hey Dan,

    Yep, I'm very new at using CF, so I pretty much stink at it compared to you all.  However, I fixed my one problem in that I don't need

    to do anything with SQL queries with onclick.  I combined a bunch of forms into one and process stuff on that page.  Matter of fact,

    I needed to do that.

    However, what I do have a problem with is one last part of my keeping checkbox values when paging.  I can do almost everything,

    meaning, keep track of checkbox values when checked by having a list of those values in session.  I can check the boxes when

    I go back to the page with a simple <CFIF> block when the checkboxes are created for the page.

    The issue I have now is how I can delete a value from the session list when a checkbox is unchecked.  I don't know if I should

    keep track of the exact page number, or whatnot.  All I have now is a list of node ids.

    Any ideas?

    Thanks,

    Ed

    Inspiring
    April 27, 2011

    Regarding:

    The issue I have now is how I can delete a value from the session list when a checkbox is unchecked.

    Reset the session variable when you process that form submission.