JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class='form-group'>
<input type='checkbox' name='check[]' value='1' checked />aaa
<input type='checkbox' name='check[]' value='1' />bbb
<input type='checkbox' name='check[]' value='1' />ccc
<input type='checkbox' name='check[]' value='1' />ddd
<input type='checkbox' name='check[]' value='1' checked />eee
<input type='checkbox' name='check[]' value='1' />fff
<div id='show' class='col-sm-4'></div>
</div>
<div class='form-group'>
<label class='control-label col-sm-2' for='livello'>Livello:</label>
<div class='col-sm-4'>
<input type='text' class='form-control' id='livello' name='livello'>
</div>
</div>
JavaScript
updates_(); // call on load
$("input[type=checkbox]").change(function() {
updates_(); //call update fn
})
function updates_() {
var str = '';
//loop through checkboxes
$(".form-group > input[type=checkbox]").each(function() {
str += $(this).is(':checked') ? 1 : 0; //append 0 or 1 depending on if checked or not
})
$("#livello").val(str) //addd value to input box
}