Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-31-2004, 05:49 PM   PM User | #1
samurai
New to the CF scene

 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
samurai is an unknown quantity at this point
Simple JS Question

I have begun renovation of an old website of mine, and I would like some help. I hope to include a "random quote" bar to the side of each page. No problem. I have coded the array and random number and display properties, and everything works fine.

However, as I have it now, the quote array (about 30 quotes so far) is included in the code for each page I wish to include the random quote bar on. This works, but of course makes adding new quotes difficult since I have to go through each page and put them in again and again. I do know Java, but I have very little experience with JS, and I was wondering what JS syntax would give me the ability to access my large quote array from a single file, which I could easily add to seperately. This would allow me to add a quote to this seperate file and as a result each page with the "random quote" function would be able to retrieve the new quotes from that file.

Can JS do this?
samurai is offline   Reply With Quote
Old 01-31-2004, 06:40 PM   PM User | #2
Antoniohawk
Senior Coder

 
Join Date: Aug 2002
Location: Kansas City, Kansas
Posts: 1,518
Thanks: 0
Thanked 2 Times in 2 Posts
Antoniohawk will become famous soon enough
Sure, just make your script into an external file.

Code:
<SCRIPT type="text/javscript" SRC="http://www.mypage.com/myscript.js"></SCRIPT>
Make sure that your external script doesn't have the script tag in it and save it with the .js extension.
Antoniohawk is offline   Reply With Quote
Old 01-31-2004, 06:43 PM   PM User | #3
Garadon
Regular Coder

 
Join Date: Jul 2002
Posts: 698
Thanks: 0
Thanked 0 Times in 0 Posts
Garadon is an unknown quantity at this point
what he says, use virtual paths instead of absolute one though.
Garadon is offline   Reply With Quote
Old 01-31-2004, 06:48 PM   PM User | #4
samurai
New to the CF scene

 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
samurai is an unknown quantity at this point
perfect. that makes things much easier.

thanks for the help fellas.
samurai is offline   Reply With Quote
Old 03-02-2004, 10:53 AM   PM User | #5
Gabrielle
New Coder

 
Join Date: Jan 2004
Location: South Midlands
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Gabrielle is an unknown quantity at this point
Helped me too!

Thanks for this thread - I'm not as clear on JS as I should be, and I didn't know how to make a script external !
__________________
And is our future wounded by Philosophies our daddies had?
- - Alisha's Attic - -
Gabrielle is offline   Reply With Quote
Old 03-03-2004, 12:21 AM   PM User | #6
Antoniohawk
Senior Coder

 
Join Date: Aug 2002
Location: Kansas City, Kansas
Posts: 1,518
Thanks: 0
Thanked 2 Times in 2 Posts
Antoniohawk will become famous soon enough
If you are just starting off in javascript, head over to w3schools.com and check out their tutorial.
Antoniohawk is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 02:23 AM.


Advertisement
Log in to turn off these ads.