SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Aug 2007
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    The error is Object expected

    Hi all.

    Why this script not working?

    The error is Object expected in the line:

    var new_ = concat(concat(ore,":"), min);

    Code:
    <html>
    
    <head>
    <script>
    
    function insertColon(id){
    var stringa = document.getElementById(id).value;
    var ore = stringa.substr(0,2);
    var min = stringa.substr(2,2);
    
    var new_ = concat(concat(ore,":"), min);
    
    document.getElementById(id).value = new_;
    }
    </script>
    </head>
    
    <body>
    
    <input id="testo" type="text" name="ora" size="5" onchange="javascript:insertColon('testo')"/>
    
    </body>
    
    </html>
    Can you help me?

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    concat is for joining arrays.
    If you are inserting the colon after the first 2 characters then you may as well just create the string.

    Code:
    <html>
    
    <head>
    <script>
    
    function insertColon(id){
    	var stringa = document.getElementById(id).value;
    	var ore = stringa.substr(0,2);
    	var min = stringa.substr(2,2);
    	
    	var new_ = ore + ":" + min;
    	document.getElementById(id).value = new_;
    }
    </script>
    </head>
    
    <body>
    
    <input id="testo" type="text" name="ora" size="25" onchange="javascript:insertColon('testo')"/>
    
    </body>
    
    </html>
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    Non-Member
    Join Date
    Aug 2007
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, many thanks x your reply !
    Regards


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
  •