Custom Form with Checkboxes

Regular Participant

Custom Form with Checkboxes

I've been using the php samples and it's working well. I see there are custom fields available for use also, hoever I'm not sure if what I need to do is possible using those.


I'd like to add a custom part to the form that asks a question like "What are your favorite hobbies", but instead of a text entry I'd like it to do it with checkboxes the user can select options and then submit. Is this possible with the API?

1 REPLY 1
Employee

Our API has no restrictions on what controls you use to gather the information. The only restriction would be the length of the value that you wish to store in each custom field. By the sound of what you are looking to do I don't think that this will be a consideration.


 


Depending on how many hobbies you are providing as options and how you would like them stored I would either set aside a custom field for each option and use your programming logic to loop through the options and set each one to true if the box was checked, or group all of the answers togethed and store it in one Field. The following high-level explanations should help:


 


If you were to have 10 available hobbies you could rename CustomField1 - 10 accordingly. CustomField1 would now be 'Arts & Crafts' and so on. You could then populate the value (true of false) of each checkbox into the appropriate node in the contact's XML data. If the person checked off Arts & Crafts you would add <CustomField1>True</CustomField1> to the XML being submitted to the API.


 


The other option would be to loop through the checkbox values in your script and concatenate a string that contains all of their answers. You could then store that in one or more of the CustomFields.


 


Information on Contact Details Field Lengths can be found here http://constantcontact.custhelp.com/cgi-bin/constantcontact.cfg/php/enduser/std_adp.php?p_faqid=2217

Dan H

Support Engineer, Constant Contact

Developer Portal

View API documentation, code samples, get your API key.

Visit Page