Is there such code.

  • WTF-AComputer
  • Student
  • Student
  • No Avatar
  • Joined: Feb 12, 2008
  • Posts: 97
  • Loc: Canada
  • Status: Offline

Post March 1st, 2009, 11:55 am

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.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 1st, 2009, 11:55 am

  • RedBMedia
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 01, 2007
  • Posts: 315
  • Status: Offline

Post March 1st, 2009, 4:25 pm

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>
Joe Hall
  • WTF-AComputer
  • Student
  • Student
  • No Avatar
  • Joined: Feb 12, 2008
  • Posts: 97
  • Loc: Canada
  • Status: Offline

Post March 1st, 2009, 4:31 pm

Can I add more quotes?
  • WTF-AComputer
  • Student
  • Student
  • No Avatar
  • Joined: Feb 12, 2008
  • Posts: 97
  • Loc: Canada
  • Status: Offline

Post March 1st, 2009, 4:40 pm

Aww man. My free hosting does not support javascript. :( Any ways around this?
  • PolishHurricane
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Feb 17, 2005
  • Posts: 1585
  • Status: Offline

Post March 1st, 2009, 6:02 pm

They support PHP or Perl? lol if they don't support javascript I doubt they do... that's pretty messed up.
There's no place like 127.0.0.1, badass part is now it's ::1
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8212
  • Loc: USA
  • Status: Offline

Post March 1st, 2009, 7:42 pm

Which host are you using?
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • RedBMedia
  • Proficient
  • Proficient
  • User avatar
  • Joined: May 01, 2007
  • Posts: 315
  • Status: Offline

Post March 2nd, 2009, 12:32 am

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!
Joe Hall
  • PolishHurricane
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Feb 17, 2005
  • Posts: 1585
  • Status: Offline

Post March 2nd, 2009, 5:57 am

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.
There's no place like 127.0.0.1, badass part is now it's ::1
  • WTF-AComputer
  • Student
  • Student
  • No Avatar
  • Joined: Feb 12, 2008
  • Posts: 97
  • Loc: Canada
  • Status: Offline

Post March 2nd, 2009, 3:46 pm

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
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8212
  • Loc: USA
  • Status: Offline

Post March 2nd, 2009, 5:03 pm

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>
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • PolishHurricane
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Feb 17, 2005
  • Posts: 1585
  • Status: Offline

Post March 2nd, 2009, 5:39 pm

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
There's no place like 127.0.0.1, badass part is now it's ::1
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8212
  • Loc: USA
  • Status: Offline

Post March 2nd, 2009, 5:47 pm

@PolishHurricane: You run your own web server or are you just saying that?
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • WTF-AComputer
  • Student
  • Student
  • No Avatar
  • Joined: Feb 12, 2008
  • Posts: 97
  • Loc: Canada
  • Status: Offline

Post March 2nd, 2009, 6:03 pm

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
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8212
  • Loc: USA
  • Status: Offline

Post March 2nd, 2009, 7:54 pm

Just to let you know... I can't get the site open.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • PolishHurricane
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Feb 17, 2005
  • Posts: 1585
  • Status: Offline

Post March 3rd, 2009, 4:33 am

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.
There's no place like 127.0.0.1, badass part is now it's ::1
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 3rd, 2009, 4:33 am

Post Information

  • Total Posts in this topic: 18 posts
  • Users browsing this forum: No registered users and 144 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
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.