How to total radio options in javascript via a submit button
<p>I found this code somewhere else on this site. I'm in the process of adapting it, but since I'm new to Javascript, I have no idea how to get the total sum to appear only after you click some kind of "Calculate" button. I've tried to do it myself, but the numbers calculate automatically, and I need a solution so that it doesn't do that. </p>

<pre><code>&lt;script type="text/javascript"&gt;
    function DisplayPrice(price){
                    var val1 = 0;
                    for( i = 0; i &lt; document.form1.price.length; i++ ){
                            if( document.form1.price[i].checked == true ){
                                    val1 = document.form1.price[i].value;
                            }
                    }

                    var val2 = 0;
                    for( i = 0; i &lt; document.form2.price2.length; i++ ){
                            if( document.form2.price2[i].checked == true ){
                                    val2 = document.form2.price2[i].value;
                            }
                    }

                    var sum=parseInt(val1) + parseInt(val2);
        document.getElementById('totalSum').value=sum;
    }
&lt;/script&gt;
</code></pre>

<p>

    Choose a number:<br>
    
        <br>
        159
        <br>
        259
        <br>
    </p>

<pre><code>Choose another number:&lt;br&gt;
&lt;form name="form2" id="form2" runat="server"&gt;
    &lt;br&gt;
    &lt;input id="rdo_1" type="radio" value="345" name="price2" onclick="DisplayPrice(this.value);"&gt;345
    &lt;br&gt;
    &lt;input id="rdo_2" type="radio" value="87" name="price2" onclick="DisplayPrice(this.value);"&gt;87
    &lt;br&gt;
&lt;/form&gt;
</code></pre>

<p></p>

<p></p>
