calculating and submitting using javascript
<pre><code>function CalculateIMSUB(form) {

    var Atext = form.input_A.value;
    var Ctext = form.input_C.value;
    var Btext = form.input_B.value;
    var val = form.val.value;
    var A = eval(Atext);
    var C = eval(Ctext);
    var B = eval(Btext);

    if (isNaN(A)) 
        A = 0;
    if (isNaN(C)) 
        C = 0;    
    if (isNaN(B)) 
        B = 0;

    var answer = A + C - B;
    form.Answer.value = answer;
    var diff = answer - val;

    if (diff == 0)
        form.Answer_2.value = 'ok';
    else if (diff &lt; 0)
        form.Answer_2.value = diff;
    else        
        form.Answer_2.value = '+' + diff;

    form.input_A.value = form.input_A.value.replace(/\+/g, ",");
    form.input_B.value = form.input_B.value.replace(/\+/g, ",");
}
function calculateAll() {
    var forms = document.getElementsByTagName("form");

    for(var i = 0; i &lt; forms.length; i++ ) {
        CalculateIMSUB(forms[i]) 
    }
}

/* Collect all forms in document to one and post it */

function submitAllDocumentForms() {

    var arrDocForms = document.getElementsByTagName('form');
    var formCollector = document.createElement("form");

    with(formCollector) {
        method = "post";
        action = "process.php";
        name = "formCollector";
        id = "formCollector";
    }

    for(var ix=0; ix &lt; arrDocForms.length; ix++) {
        appendFormVals2Form(arrDocForms[ix], formCollector);
    }

    document.body.appendChild(formCollector);
    formCollector.submit();

}

/* Function: add all elements from ``frmCollectFromÂ´Â´ and 
   append them to ``frmCollectorÂ´Â´ before returning ``frmCollectorÂ´Â´*/

function appendFormVals2Form(frmCollectFrom, frmCollector) {
    var frm = frmCollectFrom.elements; 
    var nElems = frm.length;

    for(var ix = nElems - 1; ix &gt;= 0 ; ix--)
        frmCollector.appendChild(frm[ix]);

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

<p>Body</p>

<pre><code>&lt;form&gt;
    &lt;input type="hidden" name="formID" value="hello"/&gt;
    &lt;input type="hidden" name="redirect_to" value=""/&gt;
    &lt;INPUT TYPE=TEXT NAME="input_1" SIZE=10&gt;
    &lt;INPUT TYPE=TEXT NAME="input_A"  SIZE=15&gt;/
    &lt;INPUT TYPE=TEXT NAME="input_C"style="width: 1em" maxlength="1"&gt;
    &lt;sup&gt;
        s
    &lt;/sup&gt;
    &lt;font face="Courier New"&gt;
        &lt;tt&gt;
            &lt;INPUT TYPE=TEXT NAME="input_B" SIZE=10
        &lt;/tt&gt;
        &lt;INPUT TYPE="button" VALUE="+" name="SubtractButton"
            onkeydown="CalculateIMSUB(this.form)"&gt;
        &lt;INPUT TYPE=TEXT NAME="Answer" SIZE=12&gt;
        &lt;input type="hidden" name="val" value="124" /&gt;
        124
        &lt;INPUT TYPE=TEXT NAME="Answer_2" SIZE=4&gt;
&lt;/form&gt;

&lt;input type="button" onClick="calculateAll()" value="Master calculation" /&gt;
&lt;input type="submit" name="Submit" id="button" value="Submit"                              
    onClick="submitAllDocumentForms()"&gt;

&lt;form&gt;
    &lt;input type="hidden" name="formID" value="hello"/&gt;
    &lt;input type="hidden" name="redirect_to" value=""/&gt;
    &lt;INPUT TYPE=TEXT NAME="input_1" SIZE=10&gt;
    &lt;INPUT TYPE=TEXT NAME="input_A"  SIZE=15&gt;
    /
    &lt;INPUT TYPE=TEXT NAME="input_C"style="width: 1em" maxlength="1"&gt;
    &lt;sup&gt;
        s
    &lt;/sup&gt;
    &lt;font face="Courier New"&gt;
        &lt;tt&gt;
            &lt;INPUT TYPE=TEXT NAME="input_B" SIZE=10
        &lt;/tt&gt;
        &lt;INPUT TYPE="button" VALUE="+" name="SubtractButton"
            onkeydown="CalculateIMSUB(this.form)"&gt;
        &lt;INPUT TYPE=TEXT NAME="Answer" SIZE=12&gt;
        &lt;input type="hidden" name="val" value="124" /&gt;
        124
        &lt;INPUT TYPE=TEXT NAME="Answer_2" SIZE=4&gt;
&lt;/form&gt;

&lt;input type="button" onClick="calculateAll()" value="Master calculation" /&gt;
&lt;input type="submit" name="Submit" id="button" value="Submit" 
    onClick="submitAllDocumentForms()"&gt;
</code></pre>

<p>Question </p>

<p>When I press submit only the input fields from the first form are submitted successfully since each form has the same input field names. But I cannot change the names of the input fields since I have hundreds of forms and than my calculator function will not work. How can I fix this problem? </p>
