Hi..

I created a function and now I encountered error:

Object doesn't support this property or method.

I can't find out now what is the cause of error:

here is my function code:
Code:
<script type='text/javascript'>
function sequence(varid)
{
var a=  varid.indexOf("/")
  var b=  varid.slice(0,a); 
   b =  parseInt(b)
    c= (b+1)
var f = varid.slice(a); 


 if (window.event.keyCode==13 || window.event.keyCode==10) {

 var lot_number = document.getElementsByName("lot_number")[b].value;
 var lot_number_scan = document.getElementsByName("lot_number_scan")[b].value;


var counting = document.getElementsByName("lot_number_scan");

counting = counting.length;

 var newid = c + f

lot_number_scan = lot_number_scan.replace(/(LO)/g,"-LO");
lot_number_scan = lot_number_scan.replace(/-/,"");


var check = (new RegExp(lot_number_scan,"gi").test(lot_number)); 

   if(check==true && c!=counting)
   {
       document.getElementById(newid).focus();         
   }     
   else if(check==false && c==counting)
   {
      document.getElementsByName("lot_number_scan")[b].value = ''; 
       document.getElementsByName("lot_number_scan").focus();      
   }
   else if(check==true && c==counting)
   {
     document.getElementById("issued_by").focus();      
   }
   else
   {
       document.getElementsByName("lot_number_scan")[b].value = ''; 
       document.getElementsByName("lot_number_scan").focus();     
 
   }

}
}   
</script>
Thank you/