Assigning and displaying new value in input field
<p>By some reason my function does not work. Perhaps I did some syntax error.
Function suppose to take values from two different select tags and display their sum in an input tag. Problem is that none of the tags have id, just names. Names also dynamically change based on a page. Testing revealed that values are grabbed correctly. Please suggest if you find any problems with how function is written.</p>

<pre><code>&lt;script type="text/javascript"&gt;

var productName = document.MainForm.elements["ProductCode"].value;
var selectRightName = "SELECT___" + productName + "___23";
var selectLeftName = "SELECT___" + productName + "___24";
var formQty = "QTY." + productName;

var Quantity1 = document.MainForm.elements[selectRightName].value;
var Quantity2 = document.MainForm.elements[selectLeftName].value;

if (Quantity1 == 75)
    Quantity1 = 1
else if (Quantity1 == 196)
    Quantity1 = 2
else if (Quantity1 == 197)
    Quantity1 = 3
else if (Quantity1 == 198)
    Quantity1 = 4
else if (Quantity1 == 199)
    Quantity1 = 5

if (Quantity2 == 76)
    Quantity2 = 1
else if (Quantity2 == 200)
    Quantity2 = 2
else if (Quantity2 == 201)
    Quantity2 = 3
else if (Quantity2 == 202)
    Quantity2 = 4
else if (Quantity2 == 203)
    Quantity2 = 5

var QtyUpdated = Quantity1 + Quantity2;

var Qty = document.MainForm.elements[formQty].value;



$(document).ready(function()
     $('input[name=selectRightName]').change( function() {

    MainForm.elements[formQty].value = QtyUpdated;
    $('input[name=formQty]').html(QtyUpdated);
 }

  }); 

})

&lt;/script&gt;
</code></pre>
