JSFiddle - React, Tailwind, and code Playground

by Sherali Turdiyev

HTML

Total
<input type="text" id="count" value="$0" readonly />
<div>
     <h4>Contact plugin</h4>

    <input type="radio" name="pak1" class="mnozstvi_sleva" value="4&#x00A;Qty" onClick="changeText(0, this.name)">No
    <br>
    <input type="radio" class="mnozstvi_sleva" onclick="changeText(5, this.name)" value="2&#x00A;Qty" name="PAk1">Yes!
     <h4> Mailing list</h4>

    <input type="radio" class="mnozstvi_sleva" onclick="changeText(0, this.name)" value="2&#x00A;Qty" name="PAk21">No
    <input type="radio" class="mnozstvi_sleva" onclick="changeText(10, this.name)" value="2&#x00A;Qty" name="PAk21">Yes</div>
<hr>
<div>
     <h4>Contact plugin</h4>

    <input type="radio" name="pak3" class="mnozstvi_sleva" value="4&#x00A;Qty" onClick="changeText(0, this.name)">No
    <br>
    <input type="radio" class="mnozstvi_sleva" onclick="changeText(5, this.name)" value="2&#x00A;Qty" name="PAk3">Yes!
     <h4> Mailing list</h4>

    <input type="radio" class="mnozstvi_sleva" onclick="changeText(0, this.name)" value="2&#x00A;Qty" name="PAk31">No
    <input type="radio" class="mnozstvi_sleva" onclick="changeText(10, this.name)" value="2&#x00A;Qty" name="PAk31">Yes</div>
<hr>

JavaScript

var groups = {};

function changeText(value, group) {
    var sum = 0;

    console.log(group);
    groups[group.toLowerCase()] = value;

    Object.keys(groups).forEach(function (key) {
        sum += groups[key]
    });
    document.getElementById('count').value = 10 * sum;
}

console.log(document.forms);