SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Object doesn't support this propert or method

    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/

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,718
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newphpcoder View Post
    Object doesn't support this property or method.
    That's most likely due to an HTML element not having what is expected by the code.

    What HTML code do you have, which the javascript code is supposed to work with?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It works now by this 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>
    I just comment the : document.getElementsByName("lot_number_scan").focus();

    Thank you


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •