I got stuck on a really simple task. I have several JavaScript function, but I am bad at JS so cannot solve this. I need to put it inside the for loop. Please help. My solution doesn't work. The logic is down - my code is awful help.
FUNCTION WITHOUT LOOP
<script>
var c1 = 14.94;
var c2 = 12.20;
function changeq() {
    var q1 = parseInt(document.getElementById('q1').value);
    var t1 = q1 * c1;
    var total1 = t1.toFixed(2);
    document.getElementById('ukupno1').innerHTML = total1;
}
function changeq(2) {
    var q2 = parseInt(document.getElementById('q2').value);
    var t2 = q2 * c2;
    var total2 = t2.toFixed(2);
    document.getElementById('ukupno2').innerHTML = total2;
}
</script>
FUNCTION INSIDE LOOP - WRONG
 <script>
    var c1 = 14.94;
    var c2 = 12.20;
var fncs = [];
for (var i = 0; i < 3; i++) {
funcs[i] = (function(index) {
    return function changeq[i] {
    var q[i] = parseInt(document.getElementById('q[i]').value);
    var t[i] = q[i] * c[i];
    var total[i] = t[i].toFixed(2);
    document.getElementById('ukupno[i]').innerHTML= total[i];
    }
    </script>
 
    