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

saving checkbox info

Explorer ,
Oct 21, 2008 Oct 21, 2008
I'm sorry if this is a stupid question and is someplace in all the docs. I've searched the docs, but either I don't understand, or I'm just not finding what I'm looking for. Here's my problem.

I have a table that holds a keycode and a keyvalue. Let's call it keytable. It's something like this:
a = military (a is the keycode and military is the keyvalue)
b= individual
c = business and so on for about 26 variables.

I'm displaying a form on my screen that is reading a table (lets call it formtable) that has a keycode in it also. If the keycode in this table has an "a" as the value, it means that it's military and the checkbox should display checked.

So after I do the query on formtable, it pulls out all the records and depending if there is something in the formtable.keycode field, shows it as checked. At this point, all is good.

Now, if I want to take the checkmark off military, and put one on individual and one on business, that's where the problem comes in. I don't know how to write it back to the file that the checkmarks have changed. I've tried arrays and can't get that to work. I must be doing something wrong. Can someone give me some sample code of how I might go about this? I hope this isn't too confusing. Thanks.
380
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 ,
Oct 21, 2008 Oct 21, 2008
cookies are often used to preserve data entered on forms by users. This forum is a good example. When you log in, there is a "remember me" option. If you select it, a cookie is set and the next time you come to the forum, you are still logged in.
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 ,
Oct 22, 2008 Oct 22, 2008
I can see how that would be a good use, but for our use, we need to write this to a database. Any other suggestions?
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 ,
Oct 22, 2008 Oct 22, 2008
tgoold wrote:
> I can see how that would be a good use, but for our use, we need to write this to a database. Any other suggestions?

The easy -sledge hammer- approach is that when the form is submitted,
delete all the relevant records from the keytable. Then insert new
record(s) into the keytable based on the checkbox value(s) from the form.

This will probably create unnecessary transactions in the database when
the data did not actually change in the form, but it is very simple to code.

If that is not satisfactory, you need to do something to know when the
data has changed and what needs to be done. You can either store the
current data state in a persistent variable such as session when you
query it to display the form. Or you can re-query the database after
the form is submitted.

With the current data state and the data form the form, you just loop
over the values and compare one to the other to know if values have been
added or removed and run appropriate insert and delete queries against
the database.
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 ,
Oct 22, 2008 Oct 22, 2008
LATEST
Thanks. I think I'll try the last suggestion of saving the data, then comparing by a query.
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