Is there such code.

  • WTF-AComputer
  • Student
  • Student
  • WTF-AComputer
  • Posts: 97
  • Loc: Canada

Post 3+ Months Ago

On the website I've been developing over the past week or so with the help from the fine people here on this site I am looking to add some sort of saying generator...


That probably did not make sense so I'm going to explain what it would do. First, take a look at the site. http://www.kiplingbaptist.com/ Now if you look directly at the top of the site I have a picture of the church.

To the right of this picture I am trying to make something that will add a random phrase.

Like every time they visit the site a new saying will popup from like a preset bunch.

I'm sure this is possible. I think I've seen it before. Anyways, if you want the source to my site or something to be able to help me just post so here.

Thanks a lot you guys here are amazing.
  • RedBMedia
  • Proficient
  • Proficient
  • User avatar
  • Posts: 315

Post 3+ Months Ago

Paste the following javascript in your HTML source code where you want the quotes to appear. Oh and add your own quotes!

Code: [ Select ]
<SCRIPT LANGUAGE="JavaScript">
//store the quotations in arrays
quotes = new Array(6);
authors = new Array(6);
quotes[0] = "I have a new philosophy. I'm only going to dread one day at a time.";
authors[0] = "Charles Schulz";
quotes[1] = "Reality is the leading cause of stress for those in touch with it.";
authors[1] = "Jack Wagner";
quotes[2] = "Few things are harder to put up with than the annoyance of a good example.";
authors[2] = "Mark Twain";
quotes[3] = "The pure and simple truth is rarely pure and never simple.";
authors[3] = "Oscar Wilde";
quotes[4] = "There's no business like show business, but there are several businesses like accounting.";
authors[4] = "David Letterman";
quotes[5] = "Man invented language to satisfy his deep need to complain.";
authors[5] = "Lily Tomlin";

//calculate a random index
index = Math.floor(Math.random() * quotes.length);

//display the quotation
document.write("<DL>\n");
document.write("<DT>" + "\"" + quotes[index] + "\"\n");
document.write("<DD>" + "-- " + authors[index] + "\n");
document.write("</DL>\n");

//done
</SCRIPT>
  1. <SCRIPT LANGUAGE="JavaScript">
  2. //store the quotations in arrays
  3. quotes = new Array(6);
  4. authors = new Array(6);
  5. quotes[0] = "I have a new philosophy. I'm only going to dread one day at a time.";
  6. authors[0] = "Charles Schulz";
  7. quotes[1] = "Reality is the leading cause of stress for those in touch with it.";
  8. authors[1] = "Jack Wagner";
  9. quotes[2] = "Few things are harder to put up with than the annoyance of a good example.";
  10. authors[2] = "Mark Twain";
  11. quotes[3] = "The pure and simple truth is rarely pure and never simple.";
  12. authors[3] = "Oscar Wilde";
  13. quotes[4] = "There's no business like show business, but there are several businesses like accounting.";
  14. authors[4] = "David Letterman";
  15. quotes[5] = "Man invented language to satisfy his deep need to complain.";
  16. authors[5] = "Lily Tomlin";
  17. //calculate a random index
  18. index = Math.floor(Math.random() * quotes.length);
  19. //display the quotation
  20. document.write("<DL>\n");
  21. document.write("<DT>" + "\"" + quotes[index] + "\"\n");
  22. document.write("<DD>" + "-- " + authors[index] + "\n");
  23. document.write("</DL>\n");
  24. //done
  25. </SCRIPT>
  • WTF-AComputer
  • Student
  • Student
  • WTF-AComputer
  • Posts: 97
  • Loc: Canada

Post 3+ Months Ago

Can I add more quotes?
  • WTF-AComputer
  • Student
  • Student
  • WTF-AComputer
  • Posts: 97
  • Loc: Canada

Post 3+ Months Ago

Aww man. My free hosting does not support javascript. :( Any ways around this?
  • PolishHurricane
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1585

Post 3+ Months Ago

They support PHP or Perl? lol if they don't support javascript I doubt they do... that's pretty messed up.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

Which host are you using?
  • RedBMedia
  • Proficient
  • Proficient
  • User avatar
  • Posts: 315

Post 3+ Months Ago

WTF-AComputer wrote:
Aww man. My free hosting does not support javascript. :( Any ways around this?


What??? How does a host not support javascript??? JS is a client side language. It doesn't even go on the server. Just paste what I gave you directly in your HTML file, it has absolutely nothing to do with your host!
  • PolishHurricane
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1585

Post 3+ Months Ago

RedBMedia wrote:
What??? How does a host not support javascript??? JS is a client side language. It doesn't even go on the server. Just paste what I gave you directly in your HTML file, it has absolutely nothing to do with your host!


Wrong, The host could be stripping out JavaScript from all the files due to people attempting to get around advertising banners placed at the top or whatever they use, it is entirely possible.
  • WTF-AComputer
  • Student
  • Student
  • WTF-AComputer
  • Posts: 97
  • Loc: Canada

Post 3+ Months Ago

I am using freewebs and as soon as I click edit html. And then click done. Freewebs adds a code around it. Something like <noscript> or something.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

I'm pretty sure freewebs allows Javascript... at least I've used freewebs before and never had problems with it... I've used javascript on it with no problem.

I also looked over their terms of service, privacy policy and the abuse policy and nowhere does it says anything about Javascript... maybe the possibly silently changed ...

try the following code:
JAVASCRIPT Code: [ Select ]
<script type="text/javascript" language="JavaScript">
alert('Javascript on')
//-->
</script>
  1. <script type="text/javascript" language="JavaScript">
  2. alert('Javascript on')
  3. //-->
  4. </script>
  • PolishHurricane
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1585

Post 3+ Months Ago

I recommend that you get a free host that supports PHP or another server-side scripting language. If you do the random quote stuff on the server-side (using PHP), then it will be a lot cleaner coming out to the browser and there's no possible browser javascript support issues, and you can do a lot more later on with PHP too!

I found this free host that looked pretty decent on google: http://byethost.com/

Doesn't beat running your own web server though :P
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

@PolishHurricane: You run your own web server or are you just saying that?
  • WTF-AComputer
  • Student
  • Student
  • WTF-AComputer
  • Posts: 97
  • Loc: Canada

Post 3+ Months Ago

Freewebs is all I understand how to use... I did most of the codeing along with the help from the fine people here.

But hosting is 100% new to me. I've tried many places this was the best understood for me. So far the only one that I was actually able to get something on the net with.



Added:

I messed something up. It is not working now.

Code: [ Select ]
<SCRIPT LANGUAGE="JavaScript">
//store the quotations in arrays
quotes = new Array(6);
authors = new Array(6);
quotes[0] = "Give, and it shall be given to you. For whatever measure you deal out to others, it will be dealt to you in return.";
authors[0] = ".";
quotes[1] = "Praying always with all prayer and supplication in the Spirit, and watching thereunto with all perseverance and supplication for all saints.";
authors[1] = "Ephesians 6:18";
quotes[2] = "Work hard and become a leader; be lazy and never succeed.";
authors[2] = "Proverbs 12:24";
quotes[3] = "I know the plans I have for you, declares the Lord, plans to prosper you and not to harm you, plans to give you hope and a future.";
authors[3] = "Jeremiah 29:11";
quotes[4] = "Therefore, do not worry about tomorrow, for tomorrow will worry about itself. Each day has enough trouble of its own.";
authors[4] = Matthew 6:34;
quotes[5] = "Above all, love each other deeply, because love covers over a multitude of sins. Offer hospitality to one another without grumbling ";
authors[5] = "1 Peter 4:8-9";


//calculate a random index
index = Math.floor(Math.random() * quotes.length);

//display the quotation
document.write("<DL>\n");
document.write("<DT>" + "\"" + quotes[index] + "\"\n");
document.write("<DD>" + "-- " + authors[index] + "\n");
document.write("</DL>\n");

//done
</SCRIPT>
  1. <SCRIPT LANGUAGE="JavaScript">
  2. //store the quotations in arrays
  3. quotes = new Array(6);
  4. authors = new Array(6);
  5. quotes[0] = "Give, and it shall be given to you. For whatever measure you deal out to others, it will be dealt to you in return.";
  6. authors[0] = ".";
  7. quotes[1] = "Praying always with all prayer and supplication in the Spirit, and watching thereunto with all perseverance and supplication for all saints.";
  8. authors[1] = "Ephesians 6:18";
  9. quotes[2] = "Work hard and become a leader; be lazy and never succeed.";
  10. authors[2] = "Proverbs 12:24";
  11. quotes[3] = "I know the plans I have for you, declares the Lord, plans to prosper you and not to harm you, plans to give you hope and a future.";
  12. authors[3] = "Jeremiah 29:11";
  13. quotes[4] = "Therefore, do not worry about tomorrow, for tomorrow will worry about itself. Each day has enough trouble of its own.";
  14. authors[4] = Matthew 6:34;
  15. quotes[5] = "Above all, love each other deeply, because love covers over a multitude of sins. Offer hospitality to one another without grumbling ";
  16. authors[5] = "1 Peter 4:8-9";
  17. //calculate a random index
  18. index = Math.floor(Math.random() * quotes.length);
  19. //display the quotation
  20. document.write("<DL>\n");
  21. document.write("<DT>" + "\"" + quotes[index] + "\"\n");
  22. document.write("<DD>" + "-- " + authors[index] + "\n");
  23. document.write("</DL>\n");
  24. //done
  25. </SCRIPT>
Moderator Remark: ; Added [code] tags
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

Just to let you know... I can't get the site open.
  • PolishHurricane
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1585

Post 3+ Months Ago

Bogey wrote:
@PolishHurricane: You run your own web server or are you just saying that?


Yes, I don't have a giant hosting company, but yes, if you have decent internet with decent upload speed and your ISP doesn't block the port, then you can host your own web server from your house. You can buy your domain name somewhere (like godaddy) & get free DNS name server hosting (unless you want to run your own name server). If you're really crafty, you can even host your own e-mail without your ISP realizing it (usually they block that though), but Google Hosts E-Mail now, so I use them, saves me from worrying about the mail server, including keeping the server on, receiving/sending & sending mail that doesn't look like spam.
  • RedBMedia
  • Proficient
  • Proficient
  • User avatar
  • Posts: 315

Post 3+ Months Ago

I have run my own web servers in the past and for me it wasn't worth it! its a major pain in the butt, and on top of that, you can't flow a lot of traffic through it on a regular broadband connection that your ISP hands out. That's why I just go through a hosting company, its easier and more reliable.
  • WTF-AComputer
  • Student
  • Student
  • WTF-AComputer
  • Posts: 97
  • Loc: Canada

Post 3+ Months Ago

I rewrote it again. And this is what I got but it still does not work at all.

<SCRIPT LANGUAGE="JavaScript">
//store the quotations in arrays
quotes = new Array(6);
authors = new Array(6);
quotes[0] = "Give, and it shall be given to you. For whatever measure you deal out to others, it will be dealt to you in return.";
authors[0] = ".";
quotes[1] = "Praying always with all prayer and supplication in the Spirit, and watching thereunto with all perseverance and supplication for all saints.";
authors[1] = "Ephesians 6:18";
quotes[2] = "Work hard and become a leader; be lazy and never succeed.";
authors[2] = "Proverbs 12:24";
quotes[3] = "I know the plans I have for you, declares the Lord, plans to prosper you and not to harm you, plans to give you hope and a future.";
authors[3] = "Jeremiah 29:11";
quotes[4] = "Therefore, do not worry about tomorrow, for tomorrow will worry about itself. Each day has enough trouble of its own.";
authors[4] = Matthew 6:34;
quotes[5] = "Above all, love each other deeply, because love covers over a multitude of sins. Offer hospitality to one another without grumbling ";
authors[5] = "1 Peter 4:8-9";


//calculate a random index
index = Math.floor(Math.random() * quotes.length);

//display the quotation
document.write("<DL>\n");
document.write("<DT>" + "\"" + quotes[index] + "\"\n");
document.write("<DD>" + "-- " + authors[index] + "\n");
document.write("</DL>\n");

//done
</SCRIPT>
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8413
  • Loc: USA

Post 3+ Months Ago

My computer wouldn't be able to carry all that... but that sounds cool.

Post Information

  • Total Posts in this topic: 18 posts
  • Users browsing this forum: No registered users and 33 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.