Skip to content

Instantly share code, notes, and snippets.

@spencejs
Created November 5, 2013 07:22
Show Gist options
  • Save spencejs/7315154 to your computer and use it in GitHub Desktop.
Save spencejs/7315154 to your computer and use it in GitHub Desktop.
Show Form Fields Based On Field Value
function toggleFields() {
$('.additional-field').hide();
var selected = $('#business-type').val();
switch (selected) {
case 1:
$('#soletrader').show();
break;
case 3:
$('#publicsector').show();
break;
case 5:
$('#charity').show();
break;
}
}
toggleFields();
$('#business-type').change(toggleFields);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment