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 03-01-2003, 05:09 AM   PM User | #1
samcosty
New to the CF scene

 
Join Date: Mar 2003
Location: southwest
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
samcosty is an unknown quantity at this point
Calling random text from external file

I am looking for a quick way to update libraries of quotes, either randomly generated or or viewed based on subject, author, text, etc. The key thing I would like to do is have either a text file w/delimiters (if needed), or a js file that holds content. The script would call from the external file. The obvious reason for this is that once one has say hundreds of quotes, it gets messy dealing with arrays, etc. At this point I thought js would be good cause it can be totally client side. The external file of quotes can be added, updated, edited quickly and from anywhere, including my PDA with a text editor. Unless I am missing something in my search through this forum and at other scripting sites, there does not appear to be anything like this. Would love some very specific help as I can do enough coding to tweak scripts but am not a coder by nature.

thanks...
samcosty is offline   Reply With Quote
Old 03-01-2003, 05:31 AM   PM User | #2
orangehairedboy
New Coder

 
Join Date: Mar 2003
Location: Tampa, FL
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
orangehairedboy is an unknown quantity at this point
JavaScript running on a client PC cannot open external files for security purposes.

The best thing to use would be Perl or PHP...but if you need to use Javascript you can do this:

1. Create a file called quotes.js and enter the quotes like this:
Code:
var quote = new Array(20)
quote[0] = "Buy a Pentium 586/90 so you can reboot faster."
quote[1] = "2 + 2 = 5 for extremely large values of 2."
2. Put this code in your HTML file:
Code:
<script src="quotes.js"></script>
<script>
document.write(quote(Math.round(Math.random()*(quote.length-1))+1));
</script>
Well...that's the general idea...I'm sure you get the picture...anything more complicated than this and I'd recommend using PHP or Perl.

Lewis
orangehairedboy is offline   Reply With Quote
Old 03-01-2003, 05:26 PM   PM User | #3
samcosty
New to the CF scene

 
Join Date: Mar 2003
Location: southwest
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
samcosty is an unknown quantity at this point
Tardy thanks

Lewis:
I apologize for the tardy response. Got pulled away and it got late. Thanks for the assist here. At this point I think this is the idea I have to go with unless I move to some other scripting language. I coud do Perl or PHP but really like the idea of being able to have my stuff be portable if at all possible. But I guess I'll crank up my server and play around as well.

Thanks,
Sam
samcosty is offline   Reply With Quote
Old 03-01-2003, 05:48 PM   PM User | #4
orangehairedboy
New Coder

 
Join Date: Mar 2003
Location: Tampa, FL
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
orangehairedboy is an unknown quantity at this point
Alrighty then...let me know how it goes!

Lewis
orangehairedboy 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 06:09 AM.


Advertisement
Log in to turn off these ads.