Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 19th, 2004, 03:39 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Madison, Wisconsin, USA.
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default Unterminated String Constant

This is the code I am having problems with

Code:
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--Hide from old browsers
    document.bgColor="red"
    document.bgColor="white"
    document.bgColor="blue"
    document.bgColor="white"
    document.bgColor="green"
    document.bgColor="white"
    document.bgColor="blanchedalmond"
    var tNow = new Date ()
    var tlocDate = tNow.toLocaleString()
    var tDate = tlocDate.substring(0,10)
    document.write("<H2><CENTER>Welcome, today is "+tDate+"</CENTER></H2>")
    var intro1 = "Hi thanks for visiting our website, but we have moved. Please make a note "
    var intro2 = "of our new URL (www.funphonics.com) and notify the webmaster about our new "
    var intro3 = "location.  Click<A Href='http://www.scsite.com/'> here </A> or wait 15 seconds "
    var intro4 = "to be moved automatically to our new site."
    var introMsg = intro1+intro2+intro3+intro4
    document.write("<H4>FONT Color='firebrick'>"+introMsg+"</H4>
//-->    
</SCRIPT>
The red line is where the problem is. I don't see why it's causing the problem as I have entered it exactly like my Javascript textbook has it.

Ben Horne
-------------------------
I don't want to sound like I haven't made any mistakes. I'm confident I have.

Welcome to the New Age
__________________
Ben Horne
-------------------------
I don\'t want to sound like I haven\'t made any mistakes.  I\'m confident I have.

Most likely using FireFox and concocting my next Macromedia Flash project
Snibworks Forums Moderator

Welcome to the New Age
Reply With Quote
  #2 (permalink)  
Old October 19th, 2004, 03:54 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Madison, Wisconsin, USA.
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

OK, I've figured out the problem but now, I'm seeing this unformatted crap on the page:

Code:
    document.write("<H4>FONT Color='firebrick'>"+introMsg+"</H4>")
Ben Horne
-------------------------
I don't want to sound like I haven't made any mistakes. I'm confident I have.

Welcome to the New Age
Reply With Quote
  #3 (permalink)  
Old October 19th, 2004, 03:56 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

What is the code you're now using?

-Snib <><
Try new FreshView 0.2!
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
Reply With Quote
  #4 (permalink)  
Old October 19th, 2004, 04:06 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Madison, Wisconsin, USA.
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

I've e-mailed you a copy of the HTML file so you can get a look at it. As I explained in the e-mail. I've got everything else working except for the date function. The date doesn't show correctly

Ben Horne
-------------------------
I don't want to sound like I haven't made any mistakes. I'm confident I have.

Welcome to the New Age
Reply With Quote
  #5 (permalink)  
Old October 19th, 2004, 04:17 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Madison, Wisconsin, USA.
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

I should add that I need to display the date like this:

10/10/2001

Ben Horne
-------------------------
I don't want to sound like I haven't made any mistakes. I'm confident I have.

Welcome to the New Age
Reply With Quote
  #6 (permalink)  
Old October 19th, 2004, 04:58 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You want it in month/day/year or day/month/year?

It's easier with a server language like PHP (PHP's date functions are awesome) but it's pretty simple with JS.

Code:
var now = new Date();
var day = now.getDate();
var month = now.getMonth();
var year = now.getFullYear();
var current_date = day + '/' + month + '/' + year;
That should do it!

-Snib <><
Try new FreshView 0.2!
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
Reply With Quote
  #7 (permalink)  
Old October 19th, 2004, 06:54 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Madison, Wisconsin, USA.
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

Snib,

Thanks so much. I will try this code as well as another code option that one of the Flash Kit members gave me tomorrow when I'm on campus.

Ben Horne
-------------------------
I don't want to sound like I haven't made any mistakes. I'm confident I have.

Welcome to the New Age
Reply With Quote
  #8 (permalink)  
Old October 21st, 2004, 11:26 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Month is returned as 0 - 11 so you need to add one to it:
Code:
var now = new Date();
var day = now.getDate();
var month = now.getMonth() + 1;
var year = now.getFullYear();
var current_date = day + '/' + month + '/' + year;
--

Joe
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unterminated string constant cnottingham Classic ASP Databases 8 October 28th, 2011 01:43 PM
Unterminated String Constant Apocolypse2005 Javascript 2 June 22nd, 2006 08:36 AM
unterminated string constant Stubby HTML Code Clinic 1 February 3rd, 2005 05:56 AM
Unterminated String Constant Ben Horne Javascript 2 April 9th, 2004 02:26 PM
unterminated string constant mariakovacs Classic ASP Basics 3 January 26th, 2004 03:59 PM



All times are GMT -4. The time now is 06:46 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.