Javascript is not working in Chrome and IE but working in Firefox

javascript

Here is the javacript code which is working perfectly in Mozilla but not working perfectly in IE and chrome.

function updateTable(tableID) 
{ 
    alert('inside the update'); 
    var arrayTemp=new Array();
    var str='';
    var arraycount=0;
    try {
        var table = document.getElementById(tableID);
        var rowCount = table.rows.length;

        for(var i=0; i<rowCount; i++) {
            var row = table.rows[i];
            var chkbox = row.cells[4].childNodes[0];                
            if(null != chkbox && true == chkbox.checked) {

           str+=  document.getElementById("flag"+i).value;
           str+=',';
           str+=  document.getElementById("Selected"+i).value;
           str+='`';




            } 

        }
        document.forms[0].updatearray.value=str;
        alert(' value is '+document.forms[0].updatearray.value);
        document.forms[0].submit();

        alert('Checkingdddddd');
    }catch(e) {
        alert(e);
    }
}

Here the forms is not getting submitted in IE and Chrome.Please tell is there any remedy for this.

I have tested and found that document.forms("formname").submit() is only working for chrome and IE but if I use document.forms["formname"].submit it is not working in chrome and IE quite strange, a good advice from a great javascript magician is needed

Best Answer

I have found out the remedy use document.forms[0].submit as it supports in Mozilla , IE and Google chrome.

The answer is:

          Replace:

          document.forms[0].submit();

          To:

          document.forms[0].submit;