Optional text field "Other" for select/checkbox form elements

How would I go about setting up an optional "other" text field for either a select menu or multiple check-boxes? I know how to it in straight HTML and javascript but I need the optional value to be recorded in the database.

For example:

You could have a question like:
Fruit you like best:

Then you could have the options:

Then if Other is selected/checked:
Please specify: __________________ (text field)

Thanks in advance!

Join 150,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free