Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Checkbox question again

Participant ,
Mar 15, 2008 Mar 15, 2008
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
522
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 15, 2008 Mar 15, 2008
first set all to inactive, then set active for checked ones.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 17, 2008 Mar 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 17, 2008 Mar 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 17, 2008 Mar 17, 2008
They currently would like to track it in the same table (maybe the audit table will come later). There is no easy/logical way to do this ?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 19, 2008 Mar 19, 2008
Azadi,

I can set all the status to inactive based on the key and then readd the new ones that were checked as active.

But if they decide to edit something else and leave the original checkboxes intact, is there a to see if the checkboxes were not touched, so that the inactive and active process will not have to be performed ?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 19, 2008 Mar 19, 2008
LATEST
you are making your life so much more complicated by insisting on this
status preservation! really, why make it hard when you can make it simple?

the best-case scenario for you will be:
status records are stored in a separate table. you can store only
'active' status and assume that if there's no status for a record, then
it is 'inactive'.
on the edit form's action page, whether status was changed in the form
or not, delete all status for the record being edited, and insert status
'active' for all checked checkboxes.

do not make it any more harder than you need to.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 17, 2008 Mar 17, 2008
If you want to keep a history of changes, there is no good way to do it in the same table.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 18, 2008 Mar 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 18, 2008 Mar 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources