By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,818 Members | 2,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,818 IT Pros & Developers. It's quick & easy.

The error is Object expected

P: 66
Hi all.

Why this script not working?

The error is Object expected in the line:

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

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <script>
  5.  
  6. function insertColon(id){
  7. var stringa = document.getElementById(id).value;
  8. var ore = stringa.substr(0,2);
  9. var min = stringa.substr(2,2);
  10.  
  11. var new_ = concat(concat(ore,":"), min);
  12.  
  13. document.getElementById(id).value = new_;
  14. }
  15. </script>
  16. </head>
  17.  
  18. <body>
  19.  
  20. <input id="testo" type="text" name="ora" size="5" onchange="java-script:insertColon('testo')"/>
  21.  
  22. </body>
  23.  
  24. </html>
Can you help me?
Jul 4 '08 #1
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
Get rid of "java-script:" - you don't need it and even if you were to use it, it would be "javascript".

Where is concat defined?
Jul 4 '08 #2

P: 66
thanks acoder x your reply, but error of copy/paste.

The error is same.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <script>
  5.  
  6. function insertColon(id){
  7. var stringa = document.getElementById(id).value;
  8. var ore = stringa.substr(0,2);
  9. var min = stringa.substr(2,2);
  10.  
  11. var new_ = concat(concat(ore,":"), min);
  12.  
  13. document.getElementById(id).value = new_;
  14. }
  15. </script>
  16. </head>
  17.  
  18. <body>
  19.  
  20. <input id="testo" type="text" name="ora" size="5" onchange="javascript:insertColon('testo')"/>
  21.  
  22. </body>
  23.  
  24. </html>
Jul 4 '08 #3

acoder
Expert Mod 15k+
P: 16,027
concat is not defined. Did you mean to use the String object's concat() method?
Jul 4 '08 #4

P: 66
Concat is for joining arrays.

Its working now, many thanks.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <script>
  5.  
  6. function insertColon(id){
  7.     var stringa = document.getElementById(id).value;
  8.     var ore = stringa.substr(0,2);
  9.     var min = stringa.substr(2,2);
  10.  
  11.     var new_ = ore + ":" + min;
  12.     document.getElementById(id).value = new_;
  13. }
  14. </script>
  15. </head>
  16.  
  17. <body>
  18.  
  19. <input id="testo" type="text" name="ora" size="25" onchange="javascript:insertColon('testo')"/>
  20.  
  21. </body>
  22.  
  23. </html>
  24.  
Jul 4 '08 #5

acoder
Expert Mod 15k+
P: 16,027
...and for strings, e.g.
Expand|Select|Wrap|Line Numbers
  1. var new_ = ore.concat(":",min);
Anyway, glad it's working.
Jul 4 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.