const form = document.querySelector('form[id="quiz"]');
['myCheckBox1', 'myCheckBox2', 'myCheckBox3'].forEach(className => {
let element = document.querySelector(`input[class="${className}"]`);
element.setAttribute('checked', 'true');
});
form.addEventListener('change', () => {
form.querySelector('.result').innerText = Array
.from(form.querySelectorAll(':checked'))
.reduce((acc, n) => acc + +n.getAttribute('pice') + +n.getAttribute('montage'), 0);
});
form.addEventListener('change', () => {
form.querySelector('.old_result').innerText = Array
.from(form.querySelectorAll(':checked'))
.reduce((acc, n) => acc + +n.getAttribute('old_pice') + +n.getAttribute('old_montage'), 0);
});
form.dispatchEvent(new Event('change'));
<div>
<strong>ДЛИНА:</strong>
<div class="form_radio_group">
[[getImageList?
&docid=`[[*id]]`
&limit=`16`
&tvname=`pice_length`
&wrapperTpl=`slider_wrap_tpl`
&tpl=`@CODE:<div class="form_radio_group-item">
<input class="myCheckBox2" id="montage-radio-[[+idx]]" type="radio" name="montage-radio-1" montage="[[+pice]]" old_montage="[[*old_pice]]">
<label for="montage-radio-[[+idx]]">[[+title]]</label>
</div>`
]]
</div>
</div>
// Processing given placeholders
if (!empty($properties)) {
$pl = $this->makePlaceholders($properties);
$content = str_replace($pl['pl'], $pl['vl'], $content);
}