Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2004, 03:39 PM
Friend of Wrox
 
Join Date: Sep 2003
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
 
Old October 19th, 2004, 03:54 PM
Friend of Wrox
 
Join Date: Sep 2003
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
 
Old October 19th, 2004, 03:56 PM
Friend of Wrox
 
Join Date: Nov 2003
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 ;)
 
Old October 19th, 2004, 04:06 PM
Friend of Wrox
 
Join Date: Sep 2003
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
 
Old October 19th, 2004, 04:17 PM
Friend of Wrox
 
Join Date: Sep 2003
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
 
Old October 19th, 2004, 04:58 PM
Friend of Wrox
 
Join Date: Nov 2003
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 ;)
 
Old October 19th, 2004, 06:54 PM
Friend of Wrox
 
Join Date: Sep 2003
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
 
Old October 21st, 2004, 11:26 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
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





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





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