Shortening JavaScript Function
<p>I must admit, I don't know much about JavaScript that is why my question might sound little bit silly.</p>

<p>But what I'm trying to do is grab values from selected by name radio groups.</p>

<p>It looks like this</p>

<pre><code>function calc() {
    var op1 = document.getElementsByName('form[radio1]');
    var op2 = document.getElementsByName('form[radio2]');
    var op3 = document.getElementsByName('form[radio3]');

    var result = document.getElementById('result');

    result.value = 0;

    result.value = parseInt(result.value);

    for (i = 0; i &lt; op1.length; i++) {
        if (op1[i].checked) result.value = parseInt(result.value) + parseInt(op1[i].value);
    }

    for (i = 0; i &lt; op2.length; i++) {
        if (op2.options[i].selected) result.value = parseInt(result.value) + parseInt(op2[i].value);
    }

    for (i = 0; i &lt; op3.length; i++) {
        if (op3.options[i].selected) result.value = parseInt(result.value) + parseInt(op3[i].value);
    }

    return false;
}
</code></pre>

<p>And this is my form. Im using rs form for joomla. </p>

<pre><code>&lt;form action="index.php" enctype="multipart/form-data" id="userForm" method="post"&gt;

    &lt;input name="form[radio1]" value="25" id="radio20" type="radio"&gt;
        &lt;label for="radio20"&gt;Description1&lt;/label&gt;

    &lt;input name="form[radio1]" value="35" id="radio21" type="radio"&gt;
        &lt;label for="radio21"&gt;Description2&lt;/label&gt;



    &lt;input name="form[radio2]" value="20" id="radio20" type="radio"&gt;
    &lt;label for="radio20"&gt;Description1&lt;/label&gt;

    &lt;input name="form[radio2]" value="30" id="radio21" type="radio"&gt;
    &lt;label for="radio21"&gt;Description2&lt;/label&gt;


    &lt;input type="hidden" value="0" id="result" name="form[result]"&gt;

    &lt;input type="submit" class="rsform-submit-button" onclick="calc()" id="submit" name="form[submit]" value="submit"&gt;
</code></pre>

<p>And everything would be OK, as the function is working. the only trouble is that I have about 80 radiograms.</p>

<p>Is there a way to shorten it?</p>
