Help with dynamic checkboxes
Posted: 28 April 2008 02:32 PM   [ Ignore ]
Newbie
Rank
Total Posts:  28
Joined  2006-06-22

I have a situation where I need a dynamic number of checkboxes. The checkboxes actually relate to a specific “products” weblog. They keep growing in number, so I wouldn’t be able to have a unique field in Freeform for each. I know that a multiselect can be converted into a checkbox list, but unfortunately that won’t work in this situation. The layout divides out the posts by categories into columns. Is there a way with some sort of JS or PHP to take checkboxes labeled in a certain way and join them together and put them in one field on submission? I’m not really a wiz in these matters, so I don’t know what is possible. But what I would want is for there to be checkboxes output for each product in the products weblog. And on submission all the checkboxes get inserted into 1 field with a comma separating them ("dogs, cats, birds, fish").

The form I am trying to recreate is here: http://hawkridgesys.com/forms/ql-quote-form.html

Would giving each checkbox the same name with ‘[]’ at the end work or is that only for multi-select lists? Like in the documentation example here: http://www.solspace.com/docs/entry/freeform_26_form_tag/#example_3

Would this work?

<input name="products[]" value="Dogs" type="checkbox">Dogs<br>
<
input name="products[]" value="Cats" type="checkbox">Cats<br>
<
input name="products[]" value="Birds" type="checkbox">Birds<br>

Profile
 
 
Posted: 29 April 2008 06:34 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3350
Joined  2006-10-18

That definately would work! smile

Providing you’ve created the “products” field of course smile

 Signature 
Profile
 
 
Posted: 29 April 2008 07:38 PM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  28
Joined  2006-06-22

So I discovered! Thanks.

One question though. How can I do a backspace of the array? When I did a test each item in the array was separated by a space. So I just put in a comma at the end of the values (value="Dogs,"). Outputs just how I wanted...except it has a comma after the very last item as well. Is there a way I could do a backspace of 1 on the array? or at least in the email templates?

Profile
 
 
Posted: 30 April 2008 06:22 AM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3350
Joined  2006-10-18

You’re referring to the notification template? Or the Freeform:Entries loop?

Either way, it’s not exactly possible, out of the box.  confused

 Signature 
Profile
 
 
Posted: 16 July 2008 02:10 PM   [ Ignore ]   [ # 4 ]
Member
Avatar
RankRankRank
Total Posts:  55
Joined  2006-09-11

There is no tag or option to be able to separate the values of a field that holds numerous values for the template? Would love to see a line break or a comma - or anything - separating the 1-30 things someone can select in the form I have. Is there a hook we can use? Off to the docs…

Profile