• Post Reply Bookmark Topic Watch Topic
  • New Topic

make the checkbox correspond to 5 columns only in sql  RSS feed

 
John Joe
Ranch Hand
Posts: 443
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 9 checkboxes and I have limitted the selection to 5 only. The checked box will then inserted into sql. And in my sql, I have created a menu table, which has 8 columns named Type,Budget,Day, Pre1,Pre2,Pre3,Pre4 and Pre5.(Pre1,Pre2,Pre3,Pre4,Pre5 used to store checkbox value) If there are only three checke boxes are checked, the other two column will get "0". How to do that?

**User.java**



**Place.java**

 
Anayonkar Shivalkar
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,

Welcome to CodeRanch!

I doubt if I completely understand your problem.

Is it something like below:
1) Use can select 5 or less checkboxes.
2) If less checkboxes are selected, then others should get value as 0 (e.g. if checkbox 1,2 and 4 are selected, then checkbox 3 and 5 should get value as 0 in code).

Am I correct so far?

In such case, all you can do is simply initialize all 5 variables with 0 and only reassign variables which are selected. Thus unselected checkboxes (and corresponding variables) are automatically set to 0.

I hope this helps.

P.S. I didn't get first sentence: "I have 9 checkboxes and I have limitted the selection to 5 only". Is it typo? Should it be 8 (instead of 9)?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!