Skip to main content
Inspiring
March 15, 2008
Question

Checkbox question again

  • March 15, 2008
  • 4 replies
  • 608 views
I have ten checkboxes, name cb1, cb2..etc, with vaules 1, 2, etc. I have different names because the technique i use to redisplay the checkboxes required different names.

Anyways, I insert into my table using cfif isDefined("form.cb1"), etc, for each checkbox and insert the values 1, 2, etc. in to the table if the box is checked, along with a status of Active.

So far so good, but here is the problem that I am haveing :

I bring up the form in edit mode and I display all ten checkboxes, and the ones that were previously checked, I have a checkmark in them (query from the table). For example, checkboxes 1, 5, and 8 were/are checked, so those values are in the table as active and display on the screen with checkmarks.

If they decide to edit and uncheck 5, and uncheck 8 (leave 1 checked) and check 2, 3, and 4, how would I update the table to change the status of 5 and 8 from active to inactive ?

Right now, I just delete all the current entries (1, 5 and 8) and just readd the new ones 1, 2, 3, 4 as active (using primary key).

But I need to keep track of the active and inactive status. How can I do that ?

Can someone please provide some code or examples ?

Thanks
    This topic has been closed for replies.

    4 replies

    Known Participant
    March 18, 2008
    Hi,
    You can use hidden variables for this. Use a hidden variable for each check box and then assign a value in to the hidden variable on check or uncheck of the checkbox(use onclick event).Ex:if u have chkd the chkbox put the value of hidden variable as 1 and viceversa.Then use the value of hidden variable for saving.ie if hiddenvar=1 then it is active. While also showing the edit page show the chkbox's status depending on the hidden variable.

    HTH.
    Participant
    March 18, 2008
    Please let me know if this worked for you, as i am having similar problems.

    Rob

    The Worlds Fastest MP3 Search Engine:
    http://www.pixeloodle.com
    Inspiring
    March 17, 2008
    If you want to keep a history of changes, there is no good way to do it in the same table.
    Inspiring
    March 15, 2008
    first set all to inactive, then set active for checked ones.

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    March 17, 2008
    quote:

    how would I update the table to change the status of 5 and 8 from active to inactive ?

    Use an update query

    quote:

    But I need to keep track of the active and inactive status. How can I do that ?

    Create an audit table to track all the changes made, preferrably with a trigger on the table that you are upating.. if you're not familiar with triggers - then just write an insert query to your audit table.
    Inspiring
    March 17, 2008
    quote:

    Originally posted by: CF_output

    quote:

    But I need to keep track of the active and inactive status. How can I do that ?

    Create an audit table to track all the changes made, preferrably with a trigger on the table that you are upating.. if you're not familiar with triggers - then just write an insert query to your audit table.

    Depending on what you want in your audit table, triggers are not necessarily the way to go. Some of the information you want, such as the person making the change, might be a cold fusion variable.