Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to efficiently create string representation of multiple checkboxes

Status
Not open for further replies.

navrsalemile

Programmer
Feb 6, 2005
62
0
0
CA
Hi all,

I have 10 strings representing checkboxes (states) from GUI like:

String str1;
...
String str10;

I want to construct one string that represents selection of states out of these in such a way that if particular string is null or not "" then it should be concatenated into that string, otherwise skipped.
I am wondering what is the most efficient way to do that besides if-the-else?

thanks,
 
I don't think that a concatenation of strings is efficient. To be sincere, it just make no sense for me.

Can you provide more details about what you're trying to do?

Cheers,
Dian
 
I added all strings to list using add() and then in a loop I used string buffer to append if not null and not "".
So I should get something like this as a result:

"str2-str4-str10"

which means user selected checkboxes 2, 4 and 10

I guess I could have used <html:multibox> and get collection directly but not sure how to do it

thanks,
--mile
 
I am not sure what you are trying to do. From my understanding, you want to have ten checkboxs, and if a user select few of them, then a concatenation of string is displayed. Am I right?

I think you could make a checkbox array, then you just need one loop to find which one is ticked.



Chinese Java Faq Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top