I am trying to write a function to call for enabling only single checkbox to select or enable multiple selection. MultipleCheckbox(0): allow only single selection. MultipleCheckbox(1): allow multiple selection.
function MultipleCheckbox(elem){
if (elem ==0){
$('input[type="checkbox"]').on('change', function() {
$('input[type="checkbox"]').not(this).prop('checked', false);
});
} else {
$('input[type=checkbox]').each(function() {
$('input[type="checkbox"]').prop('checked', false);
});
}
}
<table style="text-align: center;">
<tbody>
<tr style="text-align: center;">
<td>
<input type="checkbox" id="Monday" data-day="1" name="Monday" value="1" class="big-checkbox" />
<label for="Monday">Mon</label>
</td>
<td>
<input type="checkbox" id="Tuesday" data-day="2" name="Tuesday" value="2" class="big-checkbox" />
<label for="Tuesday">Tues</label>
</td>
<td>
<input type="checkbox" id="Wednesday" data-day="3" name="Wednesday" value="3" class="big-checkbox" />
<label for="Wednesday">Wed</label>
</td>
<td>
<input type="checkbox" id="Thursday" data-day="4" name="Thursday" value="4" class="big-checkbox" />
<label for="Thursday">Thur</label>
</td>
<td>
<input type="checkbox" id="Friday" data-day="5" name="Friday" value="5" class="big-checkbox" />
<label for="Friday">Fri</label>
</td>
</tr>
</tbody>
</table>
2
Answers
Ok. I have a solution for you. Replace:
with:
And here is query script: