View Full Version : Thought for the Day
jerdy
10-01-2009, 07:47 PM
Hi,
I am looking for a simple way to create a Thought for the Day on my website.
I have many different phrases, all I would like to do is program the phrase to change every day.
One day it will be one phrase, the next day another. Just in simple text, nothing fancy. I'm pretty new at this, so not really sure where I should start or if I even put this in the right section (If not I apologize).
Thank you,
Jerdy
jscheuer1
10-01-2009, 10:50 PM
See:
http://www.dynamicdrive.com/dynamicindex17/dowiframe2.htm
and:
http://home.comcast.net/~jscheuer1/side/quotes.htm
jerdy
10-05-2009, 09:41 PM
Cool, I'll see what I can do with that, is there a way to randomize the phrases?
Thank you :)
jscheuer1
10-05-2009, 09:58 PM
Sure. Which one are you using?
jerdy
10-05-2009, 10:29 PM
http://home.comcast.net/~jscheuer1/side/quotes.htm
:D
jscheuer1
10-05-2009, 11:47 PM
That one's easy. In the code (which I assume you have from its demo page):
<script type="text/javascript">
/*//////////////////////////////////////////////////////
* Random or Daily Quotes Script w/optional controls
* © John Davenport Scheuer as first seen in Dynamic Drive Forums
* http://www.dynamicdrive.com/forums - user name jscheuer1
* This credit must remain for legal use. Ver Date: 4/1/2006
//////////////////////////////////////////////////////*/
var method=1 //Set to 1 for rotating daily, 0 for random each page load
var firstBold=1 //Set to 1 to bold the first letter in all quotes, 0 for not
var usecontrols=1 //Set to 1 to use controls, 0 (also uncomment style line 'A') for not
////////////BEGIN QUOTES: (Start Editing after next line)//////////
var quotes="\
Sed ut perspiciatis unde omnis iste n . . .
Set the highlighted to 0 for random.
jerdy
10-06-2009, 12:15 AM
Cool, worked perfectly :-)
I'm REALLY new at this if you can't tell lol...
How would I insert this into my webpage? I'm using dreamweaver I'm just not sure how to save and enter it into the html code.
jscheuer1
10-06-2009, 02:42 AM
Unfortunately I am so far removed from using WYSIWYG editors like DW that I can't help much there. My best suggestion would be to make your page in DW without the script, its styles, or any of its markup. Put everything else you want into the page using the DW program. Leave space for the markup by making a division that can contain it, positioned where you want that part to appear. Make a backup of that page without the script for later use/reference should the need arise. Then when you have that, use a text only editor like NotePad to insert the script and styles into the head of the page, and the markup into the division you previously created in DW to save space for it. Make sense? If not, perhaps others more familiar with DW can help you on that aspect of it in the javascript or HTML forums here.
However, if you get close and are just having a few minor problems, I can probably advise you as to how to tweak what you have (once again, in a text only editor) to get it to perform/look the way you want. All I would need at that point would be a link to a live page that shows what you have so far.
jerdy
10-09-2009, 04:37 AM
Let me first thank you for all your detailed help :)
I was trying to insert it the same way my teacher did it, unfortunately he put the template together for us so I never learned how to do it myself.
Here are some screen shots, what he did was make a folder in the directory labled "js" then at the top of the code for the page added code to refer to that folder. But what I'm confused on is where to put the code I have. Save a txt file into that folder?
Thanks again John, I'm going to try it your way too.
not a txt file - your html file in a text editor.
it's almost always easier to directly edit the code rather than trying to get a web editor to program things the way you want it.
close DW and try opening the .html (or .htm, whatever DW writes) in Notepad. See what you're actually working with.
jerdy
10-11-2009, 08:57 PM
Hey
I tried it my way and no bueno, I'm a little confused on your way as well...ah!
Here's the link:
http://metzhere.com/yogamoves/
You can see what I have done there.
Thank ya sir :)
vwphillips
10-12-2009, 07:51 AM
first get the script working by placing it in the header
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YOGAMOVES - RELAX</title>
<link href="http://metzhere.com/yogamoves/css/yoga_moves.css" rel="stylesheet" type="text/css" />
<style type="text/css">
/*Begin Quote Styles*/
#quote { /*optional styles for quote division*/
width:375px;
font-family: Verdana, Geneva, sans-serif;
font-size:12px;
color: #2829A6;
padding:3px;
text-indent:1ex;
}
#quote b { /*styles for bold element if used in quote*/
font-size:110%;
padding:0 1px;
}
#quote { /*required styles for quote division*/
position:relative;
margin:16% auto 0 auto;
}
* html #quote { /*required style for quote division for IE without javascript*/
margin-top:8%;
}
#auth { /*required styles for quote author, if used*/
position:absolute; /*required*/
bottom:5px; /*adjustable*/
right:10px; /*adjustable*/
}
/*End Quote Styles*/
</style>
<script type="text/javascript">
/*//////////////////////////////////////////////////////
* Random or Daily Quotes Script w/optional controls
* © John Davenport Scheuer as first seen in Dynamic Drive Forums
* http://www.dynamicdrive.com/forums - user name jscheuer1
* This credit must remain for legal use. Ver Date: 4/1/2006
//////////////////////////////////////////////////////*/
var method=0 //Set to 1 for rotating daily, 0 for random each page load
var firstBold=0 //Set to 1 to bold the first letter in all quotes, 0 for not
var usecontrols=0 //Set to 1 to use controls, 0 (also uncomment style line 'A') for not
////////////BEGIN QUOTES: (Start Editing after next line)//////////
var quotes="\
The body is a boat which carries the soul in the ocean of the world. If it is not strong or it has a hole, then it can't cross the ocean. So the first duty is to fix the boat. ~Baba Hari Dass^\
ENJOY LIFE...THIS IS NOT A REHEARSAL. ~Unknown^\
Some people think yoga means standing on your head, but it really means learning to stand firmly on your own two feet. ~Swami Satchidananda^\
Yoga helps you see things from a perspective that constantly strives for balance and the intimacy of the moment. ~Laureen Lucero^\
There is no such thing as a right position, but there is such a thing as a right direction. ~F. M. Alexander^\
My advice to people who sit for long periods of time...MOVE YOUR BODY… ~Laureen Lucero^\
The only place success comes before work is in the dictionary. ~Scott Goguen^\
Just be sure that you're sitting up when you're sitting down. ~Unknown^\
Relaxing is the easy part. The hard part is taking the time to do it. ~Laureen Lucero^\
Of course, the inner voice can be very scary sometimes. You listen, and then you go, 'do what? I don't wanna do that!' But you still have to pay attention to it. ~Alice Walker^\
", ///////////END QUOTES (Stop Editing, don't touch this line)////////////
thenum, thelength;
function selectQuote(qnum){
if (usecontrols){
var controls=document.getElementById?document.getElementById('qcontrols'):document.all['qcontrols']
controls.style.visibility='visible'
}
var qs=quotes.split("^")
thelength=qs.length=qs.length-1
if (typeof qnum=='undefined'){
if(method){
var qdate=new Date()
thenum=Math.ceil((qdate.valueOf()-new Date(qdate.setMonth(0)).setDate(1))/(1000*60*60*24))%(qs.length-1)
}
else
thenum=Math.floor(qs.length*Math.random())
}
else
thenum=qnum
var quotediv=document.getElementById?document.getElementById('quote'):documet.all['quote']
var theQuote=firstBold? qs[thenum].replace(/^(.)/, '<b>$1</b>') : qs[thenum]
var qHTML=quotediv.innerHTML=/~/.test(theQuote)? '"'+theQuote.replace(/~/, '"<br> <br> <span id="auth"> ~ ')+' </span>' : '"'+theQuote+'"<br> <br> '
var qh=quotediv.parentNode.offsetHeight/2-quotediv.offsetHeight/2
var as=document.getElementById?document.getElementById('auth'):document.all['auth']
quotediv.style.paddingBottom=''
if(qh<0&&!as){
qHTML=qHTML.replace(/<br>\ <br>\ $/,'')
quotediv.innerHTML=qHTML
quotediv.style.paddingBottom='10px'
}
quotediv.parentNode.style.borderRightWidth=qh<0? 0 : ''
quotediv.style.marginTop=Math.max(5, qh)+'px'
if (quotediv.parentNode.scrollTop)
quotediv.parentNode.scrollTop=0
}
if ( typeof window.addEventListener != "undefined" )
window.addEventListener( "load", function(){selectQuote();}, false );
else if ( typeof window.attachEvent != "undefined" )
window.attachEvent( "onload", function(){selectQuote();} );
else {
if ( window.onload != null ) {
var oldOnload = window.onload;
window.onload = function ( e ) {
oldOnload( e );
selectQuote();
};
}
else
window.onload = function(){selectQuote();}
}
function getQuote(){
method=0;
selectQuote();
}
function nextQuote(){
if (thenum<thelength-1)
selectQuote(thenum+1)
else
selectQuote(0)
}
function prevQuote(){
if (thenum>0)
selectQuote(thenum-1)
else
selectQuote(thelength-1)
}
</script>
</head>
<body>
<center>
<div id="header"> </div>
<div id="navigation">
<ul>
<li><a href="index.html" class="selected"><font color="#2829A6">Home</font></a></li>
<li><a href="eye_pillows.html">Eye Pillows</a></li>
<li><a href="blog.html">Blog</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
<div id="content"><center>
with
<h2>Laureen Lucero</h2>
<p><img src="http://metzhere.com/yogamoves/img/namaste.jpg" width="220" height="239" alt="namaste" />
<div id="quote">
</div>
</div>
<div id="footer">Website designed by <a href="http://www.metzhere.com">Amber Metz</a> - Background Image Provided by <a href="http://casperium.deviantart.com/">casperium</a></div>
<div id="tagline"><MARQUEE direction="right" loop="20"><h1>...Yoga to help you move through Life...</h1></MARQUEE></DIV>
</body>
</html>
once you are satisfided the code between the script tags
can go in an external .js file
and
<script type='text/javascript' src='js/thought.js'></script>
can go in the header
Also the script requires that the quote div has an ID name of 'quote'
jerdy
10-14-2009, 05:07 AM
Once again thank you guys for the help, I did attempt to follow directions, but as you can see (www.metzhere.com/yogamoves) I may have slipped up somewhere. I placed the code in the header, also created a new .js file and placed it in the js folder I created.
The quote does work, but it doesn't seem to be following my container instructions. It has a very large white area that I'm not sure how to get rid of?
:)
jscheuer1
10-14-2009, 10:26 AM
Both of the below changes should be made with a text only editor to the page at http://metzhere.com/yogamoves/
Get rid of this (highlighted):
<div id="quote">
<script type='text/javascript' src='js/quote.js'></script></div>
That file (js/quote.js) is not a valid javascript file, it is not doing anything except throwing an error.
Add this (also highlighted):
#quote { /*optional styles for quote division*/
width:375px;
font-family: Verdana, Geneva, sans-serif;
font-size:12px;
color: #2829A6;
padding:3px;
text-indent:1ex;
margin-top: 0!important;
}
vwphillips
10-14-2009, 10:44 AM
your external javascript file includes the css and script tags
it should look like this
/*//////////////////////////////////////////////////////
* Random or Daily Quotes Script w/optional controls
* © John Davenport Scheuer as first seen in Dynamic Drive Forums
* http://www.dynamicdrive.com/forums - user name jscheuer1
* This credit must remain for legal use. Ver Date: 4/1/2006
//////////////////////////////////////////////////////*/
var method=1 //Set to 1 for rotating daily, 0 for random each page load
var firstBold=0 //Set to 1 to bold the first letter in all quotes, 0 for not
var usecontrols=0 //Set to 1 to use controls, 0 (also uncomment style line 'A') for not
////////////BEGIN QUOTES: (Start Editing after next line)//////////
var quotes="\
The body is a boat which carries the soul in the ocean of the world. If it is not strong or it has a hole, then it can't cross the ocean. So the first duty is to fix the boat. ~Baba Hari Dass^\
ENJOY LIFE...THIS IS NOT A REHEARSAL. ~Unknown^\
Some people think yoga means standing on your head, but it really means learning to stand firmly on your own two feet. ~Swami Satchidananda^\
Yoga helps you see things from a perspective that constantly strives for balance and the intimacy of the moment. ~Laureen Lucero^\
There is no such thing as a right position, but there is such a thing as a right direction. ~F. M. Alexander^\
My advice to people who sit for long periods of time...MOVE YOUR BODY… ~Laureen Lucero^\
The only place success comes before work is in the dictionary. ~Scott Goguen^\
Just be sure that you're sitting up when you're sitting down. ~Unknown^\
Relaxing is the easy part. The hard part is taking the time to do it. ~Laureen Lucero^\
Of course, the inner voice can be very scary sometimes. You listen, and then you go, 'do what? I don't wanna do that!' But you still have to pay attention to it. ~Alice Walker^\
", ///////////END QUOTES (Stop Editing, don't touch this line)////////////
thenum, thelength;
function selectQuote(qnum){
if (usecontrols){
var controls=document.getElementById?document.getElementById('qcontrols'):document.all['qcontrols']
controls.style.visibility='visible'
}
var qs=quotes.split("^")
thelength=qs.length=qs.length-1
if (typeof qnum=='undefined'){
if(method){
var qdate=new Date()
thenum=Math.ceil((qdate.valueOf()-new Date(qdate.setMonth(0)).setDate(1))/(1000*60*60*24))%(qs.length-1)
}
else
thenum=Math.floor(qs.length*Math.random())
}
else
thenum=qnum
var quotediv=document.getElementById?document.getElementById('quote'):documet.all['quote']
var theQuote=firstBold? qs[thenum].replace(/^(.)/, '<b>$1</b>') : qs[thenum]
var qHTML=quotediv.innerHTML=/~/.test(theQuote)? '"'+theQuote.replace(/~/, '"<br> <br> <span id="auth"> ~ ')+' </span>' : '"'+theQuote+'"<br> <br> '
var qh=quotediv.parentNode.offsetHeight/2-quotediv.offsetHeight/2
var as=document.getElementById?document.getElementById('auth'):document.all['auth']
quotediv.style.paddingBottom=''
if(qh<0&&!as){
qHTML=qHTML.replace(/<br>\ <br>\ $/,'')
quotediv.innerHTML=qHTML
quotediv.style.paddingBottom='10px'
}
quotediv.parentNode.style.borderRightWidth=qh<0? 0 : ''
quotediv.style.marginTop=Math.max(5, qh)+'px'
if (quotediv.parentNode.scrollTop)
quotediv.parentNode.scrollTop=0
}
if ( typeof window.addEventListener != "undefined" )
window.addEventListener( "load", function(){selectQuote();}, false );
else if ( typeof window.attachEvent != "undefined" )
window.attachEvent( "onload", function(){selectQuote();} );
else {
if ( window.onload != null ) {
var oldOnload = window.onload;
window.onload = function ( e ) {
oldOnload( e );
selectQuote();
};
}
else
window.onload = function(){selectQuote();}
}
function getQuote(){
method=0;
selectQuote();
}
function nextQuote(){
if (thenum<thelength-1)
selectQuote(thenum+1)
else
selectQuote(0)
}
function prevQuote(){
if (thenum>0)
selectQuote(thenum-1)
else
selectQuote(thelength-1)
}
jscheuer1
10-14-2009, 01:48 PM
your external javascript file includes the css and script tags
it should look like this . . .
Yes, but it would still be in the wrong spot, it shouldn't be in that division. And once added in the head, the on page version of the script would no longer be needed. In fact its external tag should replace the on page script, and only the on page script. Jerdy should still make the addition to the on page style as indicated in my previous post.
I think jerdy's main problem is that s/he doesn't seem to know what is script code vs. what is style code vs. what is markup, nor how to make script code external.
Given all of that, s/he might be better off not worrying about the external script and simply follow the instructions from my previous post in this thread. But one can learn. So good luck with it jerdy, however you decide to approach this. Just try not to do too much at once.
jerdy
10-14-2009, 05:01 PM
Hey guys,
I am just confused, if I have the external file, isn't there no need for it to be placed in the header? Or if I place it in the header...isn't there no need to for the external file?
But anywho I did try your changes John, deleted the extra code and added the style to the container but it still seemed to have that heinous white space around it? Grrr.
I don't mind trying it either way, just as long as it clicks in my brain. (God help us all haha)
Thank you guys both :)
Amber
jscheuer1
10-15-2009, 01:42 AM
Though vwphillips and I are both quite accomplished coders and have helped quite a number of folks, we do each take our own approach, and I think this is adding to your confusion. I believe that you must choose one or the other of us. Once you do and announce that choice here, hopefully the other one will bow out of this thread and whoever is left can get down to business helping you resolve this.
That said, your current live page shows none of the recommendations I made. Until it does, I cannot be of much further help except to point you to this working demo of your page with those recommendations in place:
http://home.comcast.net/~jscheuer1/side/yoga_quote.htm
If you use your browser's 'view source' and copy and paste that code into a text only editor and save it as whatever.htm, it will be a working page for your site.
jerdy
10-19-2009, 02:11 AM
Great, thank you all for the help. It's very appreciated :)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.