Skip to content

Instantly share code, notes, and snippets.

@carolineschnapp
Last active December 5, 2025 08:53
Show Gist options
  • Select an option

  • Save carolineschnapp/6081278 to your computer and use it in GitHub Desktop.

Select an option

Save carolineschnapp/6081278 to your computer and use it in GitHub Desktop.
Example where customer tags are collected in the REGISTRATION form, and more than one tag. The server expects a comma-separated list of tags. So we give that list to him via a hidden input field that we update with JavaScript. In the SIGNUP form, it'd be the same code except you replace customer[tags] with contact[tags].
<p>I am interested in:</p>
<p>
<input type="checkbox" class="interested-in" value="sunsets">Sunsets<br />
<input type="checkbox" class="interested-in" value="piña coladas">Piña coladas<br />
<input type="checkbox" class="interested-in" value="getting lost in the rain">Getting lost in the rain<br />
<input type="checkbox" class="interested-in" value="songs by rupert holmes">Songs by Rupert Holmes<br />
</p>
<!-- this is what is submitted to the server -->
<input type="hidden" name="customer[tags]" />
<script>
jQuery(function() {
jQuery('.interested-in').change(function() {
var tags = '';
jQuery('.interested-in:checked').each(function(){
tags += jQuery(this).val() + ',';
});
jQuery('[name*="tags"]').val(tags);
});
});
</script>
@speets

speets commented Oct 16, 2013

Copy link
Copy Markdown

Any way for the customer to come back and modify their tags or is this only available when they first register?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment