UPDATE: I managed to make it work but the value does not save in the database
function render_field( $field ) {
?>
<label for="total">Total:</label>
<input id="total" type="text" disabled readonly name="<?php echo esc_attr($field['name']) ?>" value='8'>
<script type="text/javascript">
let total = 0;
document.querySelectorAll('input[type="number"]').forEach(el=>total+=+el.value);
document.querySelector('#total').value = total;
console.log(total);
</script>
<?php
}
}
// create field
new acf_field_sum();