[Solved] JavaScript Error: expected }

makumbi
 
on Jun 29, 2022 07:28 AM
234 Views

Please help I am trying to run this code but am getting error expected }

I have added it but it is still appearing.

Please help.

<script type="text/javascript">
  function enter(obj) {
      var tr = obj.parentNode.parentNode;
      var cellIndex = obj.parentNode.cellIndex;
      var rowIndex = obj.parentNode.parentNode.rowIndex;
      if (event.keyCode == 37) //Left
      {
          if (cellIndex > 0)
              tr.parentNode.rows[rowIndex].cells[cellIndex - 1].getElementsByTagName('INPUT')[0].focus();
          GetSelectedRow(obj)
          // return;
      }
      if (event.keyCode == 38) //Up
      {
          if (rowIndex > 1)
              tr.parentNode.rows[rowIndex - 1].cells[cellIndex].getElementsByTagName('INPUT')[0].focus();
          GetSelectedRow(obj)
         // return;
      }
      if (event.keyCode == 39) //Right
      {
          if (cellIndex < tr.cells.length - 1)
              tr.parentNode.rows[rowIndex].cells[cellIndex + 1].getElementsByTagName('INPUT')[0].focus();
          GetSelectedRow(obj)
          //return;
      }
      if (event.keyCode == 40) //Down
      {
          if (rowIndex < tr.parentNode.rows.length - 1)
              tr.parentNode.rows[rowIndex + 1].cells[cellIndex].getElementsByTagName('INPUT')[0].focus();
          GetSelectedRow(obj)
       //return;
      }
  };
  
  var prm = Sys.WebForms.PageRequestManager.getInstance();
  if (prm != null) {
      prm.add_endRequest(function (sender, e) {
          if (sender._postBackSettings.panelsToUpdate != null) {
              var rowIndex = parseInt(document.getElementById("hfRowIndex").value);
              var row = document.getElementById("StudentGridMarks").rows[rowIndex + 2];
              if (typeof (row) != "undefined") {
                  var controls = row.getElementsByTagName("INPUT");
                  for (var i = 0; i < controls.length; i++) {
                      switch (controls[i].className) {
                          case "Score":
                              controls[i].focus();
                              break;
                          case "Remark":
                              controls[i].focus();
                              break;
                          default:
                      }
 
                  }
              }
          }
       
      });
</script>

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Jun 29, 2022 08:05 AM
makumbi says:
if (prm != null) {

Ending bracket is missing. Add it.

var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm != null) {
    prm.add_endRequest(function (sender, e) {
        if (sender._postBackSettings.panelsToUpdate != null) {
            var rowIndex = parseInt(document.getElementById("hfRowIndex").value);
            var row = document.getElementById("StudentGridMarks").rows[rowIndex + 2];
            if (typeof (row) != "undefined") {
                var controls = row.getElementsByTagName("INPUT");
                for (var i = 0; i < controls.length; i++) {
                    switch (controls[i].className) {
                        case "Score":
                            controls[i].focus();
                            break;
                        case "Remark":
                            controls[i].focus();
                            break;
                        default:
                    }
                }
            }
        }
    });
}