Reference issue with Javascript
<p>I have an array of objects cached on client side using JS array. </p>

<pre><code>var scannerDictionary = new Array();            //Holds all scanners unmodified
var modifiedScannerDictionary = new Array();    //Holds all scanners with modified values
</code></pre>

<p>The properties of each object is set/changed using GUI and updated in the object. Each object contains list of InputParameters (array of Parameter class containing Name, Value and other members).</p>

<p>Please have a look on GUI.</p>

<p><img src="http://i.stack.imgur.com/cTH89.png" alt="enter image description here">
<img src="http://i.stack.imgur.com/hTgNf.png" alt="enter image description here">
<img src="http://i.stack.imgur.com/oZlrJ.png" alt="enter image description here">
<img src="http://i.stack.imgur.com/G29WY.png" alt="enter image description here"></p>

<p>Below is the code i used to render the controls -</p>

<pre><code>function renderControls(scannerId) {
        var currentScanner = modifiedScannerDictionary[scannerId];

        //Render Input Parameters
        $("#tblInputCriteria").find('tr:gt(5)').remove();
        for(var i=0;i&lt;currentScanner.InputParameters.length;i++) {
            var propType = currentScanner.InputParameters[i].DataType;
            var inParName = currentScanner.InputParameters[i].Name;

            switch(propType) {
                case 0: //Number
                    var eRow1 = $("#tblInputCriteria").find('#emptyNumRow').clone();
                    $(eRow1).removeClass('hidden').attr('id', 'Row_'+currentScanner.InputParameters[i].Name);
                    $(eRow1).appendTo($('#tblInputCriteria'));
                    var prop1 = $(eRow1).find('#InNumPropName');
                    $(prop1).attr('id', 'InNumPropName_'+currentScanner.InputParameters[i].Name);
                    var propName1 = currentScanner.InputParameters[i].Name;
                    $(prop1).html(propName1);
                    var propVal1 = $(eRow1).find('#InNumPropValue');
                    $(propVal1).attr('id', 'InNumPropValue_'+currentScanner.InputParameters[i].Name);
                    $(propVal1).val(currentScanner.InputParameters[i].Value);
                    $(propVal1).blur(function () {
                        if(!ValidateNumber(this, propName1)) {
                            alert('Value should be numeric in ' + propName1);
                            setTimeout(function() {$(propVal1).focus();}, 100);
                        }else {
                            UpdateData(currentScanner.Id, propName1, $(propVal1).val());
                        }
                    });

                    break;
                case 1: //String
                    var eRow2 = $("#tblInputCriteria").find('#emptyStrRow').clone();
                    $(eRow2).removeClass('hidden').attr('id', 'Row_'+currentScanner.InputParameters[i].Name);
                    $(eRow2).appendTo($('#tblInputCriteria'));
                    var prop2 = $(eRow2).find('#InStrPropName');
                    $(prop2).attr('id', 'InStrPropName_'+currentScanner.InputParameters[i].Name);
                    var propName2 = currentScanner.InputParameters[i].Name;
                    $(prop2).html(propName2);
                    var propVal2 = $(eRow2).find('#InStrPropValue');
                    $(propVal2).attr('id', 'InStrPropValue_'+currentScanner.InputParameters[i].Name);
                    $(propVal2).val(currentScanner.InputParameters[i].Value);
                    $(propVal2).blur(function () {
                        UpdateData(currentScanner.Id, propName2, $(propVal2).val());
                    });
                    break;
                case 2: //Boolean
                    var eRow3 = $("#tblInputCriteria").find('#emptyBoolRow').clone();
                    $(eRow3).removeClass('hidden').attr('id', 'Row_'+currentScanner.InputParameters[i].Name);
                    $(eRow3).appendTo($('#tblInputCriteria'));
                    var prop3 = $(eRow3).find('#InBoolPropName');
                    $(prop3).attr('id', 'InBoolPropName_'+currentScanner.InputParameters[i].Name);
                    var propName3 = currentScanner.InputParameters[i].Name;
                    $(prop3).html(propName3);
                    var propVal3 = $(eRow3).find('#InBoolPropValue');
                    $(propVal3).attr('id', 'InBoolPropValue_'+currentScanner.InputParameters[i].Name);
                    $(propVal3).val(currentScanner.InputParameters[i].Value);
                    $(propVal3).blur(function () {
                        UpdateData(currentScanner.Id, propName3, $(propVal3).val());
                    });
                    break;
    }
}
}
</code></pre>

<p>PROBLEM:
The problem here is of the variables inside switch working as reference variable. So the <code>UpdateData()</code> function gets the last Name for similar type properties. i.e. if fields are of Number type then only the last property is updated by <code>UpdateData()</code> method.</p>

<p>Can anybody help me out solve this issue. Thanks for sharing your time and wisdom.</p>
