how to take value only from the checked checkbox
document.getElementById('select').onclick = function() {
var checkboxes = document.querySelectorAll('input[type="checkbox"]:checked');
for (var checkbox of checkboxes) {
document.body.append(checkbox.value + ' ');
}
}
4
4
$(document).ready(function() {
$('#select').click(function() {
$('input[type="checkbox"]:checked').each(function() { // $(':checkbox:checked')
document.body.append(this.value + ' '); // $(this).val()
});
});
});
Thank you!
4
0
4.4
4
document.getElementById('select').onclick = function() {
var checkboxes = document.getElementsByName('vechicle');
for (var checkbox of checkboxes) {
if (checkbox.checked)
document.body.append(checkbox.value + ' ');
}
}
Thank you!
4
0
Are there any code examples left?
New code examples in category ActionScript
-
ActionScript 2022-03-27 21:30:39 rabbitmq docker can access website
-
ActionScript 2022-01-26 23:16:45 truncate restart identity - syntax error at or near "identity"
-
ActionScript 2022-01-22 21:00:37 hide or remove link on print
-
ActionScript 2021-11-21 09:28:07 bootstrap
-
ActionScript 2021-11-19 13:38:17 iis appcmd stop site
-
ActionScript 2021-11-18 14:26:06 yaml reference library variable
-
ActionScript 2021-11-17 07:40:14 save docker image from local repo
-
ActionScript 2021-11-14 04:23:13 for of with index
-
ActionScript 2021-11-09 21:28:20 bootstrap 5 examples