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

Comparing Lists

New Here ,
Mar 01, 2007 Mar 01, 2007

Copy link to clipboard

Copied

In my application I use an edit form with checkboxes. There are two levels for the checkboxes, a Category and Subcategories for each Category. When the user submits the form, i need to compare what is currently in the database against what was submitted. If a Subcategory within a Category was deselected by the user, I need to remove the corresponding record from the DB. If a Category was deselected, I need to remove all the corresponding records for the Category from the DB. If a Category not previously selected has been checked then I need to insert a new record and the same if a Category and Subcategory were checked. There is no restriction that both a Category and at least one Subcategory be selected. The user can simply select a Category and no Subcategorie.

I have queried the DB for the current information, stored the results in an array and then converted the array to a list. The DB list is in the form Category, Subcategory. The information from the form is already in list form as Category, Subcategory. I am having a devil of a time figuring out the logic to find the differences and take the appropriate action. Has anyone worked on a similar project and can offer some advice?

Thanks,
Warren
TOPICS
Advanced techniques

Views

277

Translate

Translate

Report

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

correct answers 1 Correct answer

LEGEND , Mar 01, 2007 Mar 01, 2007
simple solution:

first delete current data in the db then insert new data from the form
selections...

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate
LEGEND ,
Mar 01, 2007 Mar 01, 2007

Copy link to clipboard

Copied

simple solution:

first delete current data in the db then insert new data from the form
selections...

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

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 01, 2007 Mar 01, 2007

Copy link to clipboard

Copied

Wow!!! That sounds toooo simple. I will give it a try. Sure beats breaking my head over the logic I have been trying to use. I will let you know if it works out. It sounds like it wil. Thanks.

Warren

Votes

Translate

Translate

Report

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 02, 2007 Mar 02, 2007

Copy link to clipboard

Copied

LATEST
Hi Azadi,

It worked fine. Thanks. There was still lots of logic to take care of the situation when a user checked a Category but no Subcategory or when they just checked a subcategory without checking the Category. Whew!

Warren

Votes

Translate

Translate

Report

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
Documentation