Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Closed Thread
Calling a function from XHTML document need help
Old 11-27-2008, 08:00 PM Calling a function from XHTML document need help
Junior Talker

Posts: 3
Name: Brianne
Trades: 0
I am a newbie here and I am working on a page on which, I need to display the current date. I have the javascript in an external file. My problem is that I can't get it to work. I would appreciate any help with this I've been at it for three days now. Here is the code I am using:

Code:
<head>
  <script src="dates.js" type="text/javascript"></script>
</head>


<body>
  <tr>
    <td scope="col">    
<script type="text/javascript">
showDate()
</script></td>
    <td scope="col">&nbsp;</td>
  </tr>
</body>

Last edited by hungdukie; 11-27-2008 at 08:12 PM.. Reason: keyed in incorrect src file info
hungdukie is offline
View Public Profile
 
 
Register now for full access!
Old 11-27-2008, 08:05 PM Re: Calling a function from XHTML document need help
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,528
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
It definitely won't work like that.

You'll need to use an "AJAX" call to get a date from the server that way.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
View Public Profile Visit chrishirst's homepage!
 
Old 11-27-2008, 08:10 PM Re: Calling a function from XHTML document need help
Junior Talker

Posts: 3
Name: Brianne
Trades: 0
I am trying to use a client-side call. I have the JRE and the dates.js file on my computer and the files are all in the same root folder. It should work but I get the feeling I am missing something.
hungdukie is offline
View Public Profile
 
Old 11-27-2008, 08:21 PM Re: Calling a function from XHTML document need help
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,528
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Aye so are we the code you are using. src"dates.js" isnt much use without the site to find it on.

anyhoo if you just want the date:-
Code:
<script type="text/javascript">
var today = new Date()

document.write(today.getDate() + '/' + today.getMonth() + '/' + today.getFullYear());

</script>
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
View Public Profile Visit chrishirst's homepage!
 
Old 11-27-2008, 10:57 PM Re: Calling a function from XHTML document need help
Junior Talker

Posts: 3
Name: Brianne
Trades: 0
I think I have solved the problem. The code I was using in the head section was not complete as written. The code I ended up using was:
Code:
  <head>
   <script src= "dates.js" type= "text/javascript"></script>
   <script type= "text/javascript">
     function showDate()
     document.write(Date());
   </script>
  </head>
   <body>
<caption><script type="text/javascript">
showDate();
</script></caption>
The preceding code allowed me to call an external javascript file and it passed XHTML strict 1.0 validation. Thank you for your help.
Also, I could not find a way to mark this thread as solved. Am I missing something?
hungdukie is offline
View Public Profile
 
Old 11-28-2008, 08:06 AM Re: Calling a function from XHTML document need help
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,528
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Also, I could not find a way to mark this thread as solved. Am I missing something
Nope.
I'll close it.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
View Public Profile Visit chrishirst's homepage!
 
Closed Thread     « Reply to Calling a function from XHTML document need help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22975 seconds with 12 queries