Skip to content

Instantly share code, notes, and snippets.

@sharpmachine
Last active October 23, 2015 21:01
Show Gist options
  • Select an option

  • Save sharpmachine/35f6231e8afc23ac5735 to your computer and use it in GitHub Desktop.

Select an option

Save sharpmachine/35f6231e8afc23ac5735 to your computer and use it in GitHub Desktop.
This script creates a checkbox option for users to select all the answers in the good column
var firstRadio = $('.tdNsgAnswerContainer:first-child input[type="radio"]');
var selectAllGood = [
'<div class="NsgQuestionContainer" style="padding-left: 20.8em">',
'<label>',
'<input type="checkbox" id="selectAllGood">',
'Select All Good',
'</label>',
'</div>'
].join(' ');
function isAllChecked(trueOrFalse) {
$('.tblNsgAnswersContainer').each(function() {
firstRadio.prop( 'checked', trueOrFalse )
.trigger('change');
});
}
$('.NsgQuestionContainer').first().before(selectAllGood);
$('input#selectAllGood').change(function() {
if(this.checked) {
isAllChecked(true);
} else {
isAllChecked(false);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment