Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    712
    Thanks
    165
    Thanked 0 Times in 0 Posts

    Object Doesn't support this property 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
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    There should be an error message in the browser error console.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #3
    Regular Coder
    Join Date
    Aug 2010
    Posts
    712
    Thanks
    165
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WolfShade View Post
    There should be an error message in the browser error console.
    Thats the only error. It's too hard for me to debug a javascript error.

    Thank you.

    I don't know if what's wrong in my if else if else condition.
    That's condition point out of the error.

    Thank you.

  • #4
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,133
    Thanks
    12
    Thanked 332 Times in 328 Posts
    an exact line number would be incredibly helpful.

    PS. your code will also fail in any other browser than IE (that’s the only one using window.event, all others pass the event object to the handler function)

    Edit: document.getElementsByTagName() return a list and list have almost no methods/properties (esp. not focus()). check out the line above.
    Last edited by Dormilich; 04-10-2013 at 09:48 AM.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • Users who have thanked Dormilich for this post:

    newphpcoder (04-10-2013)

  • #5
    Regular Coder
    Join Date
    Aug 2010
    Posts
    712
    Thanks
    165
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

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