/    Sign up×
Community /Pin to ProfileBookmark

Need help with Automating Text to Change Daily at Specifc Time to Site Viewers Time

[SIZE=”3″][FONT=”Palatino Linotype”][COLOR=”Navy”]Hi Everyone! I am a volunteer in ministry work, and I do pretty much all the computer related tasks, which includes computer system repair, audio/video editing, cd/dvd printing and duplication, document format and creation, etc etc. But when it comes to HTML (or other codes) I know very little. But we needed a website, so I use Homestead hosting and the Homestead (offline) Site Builder program.

Anyway, inside the sight builder program, they have the option to insert HTML Snippets. Which I use for various objects, off site tools, and other. But now I need to do something for which I have not been able to find a “premade” html code object, that can perform the task desired. I have searched and searched google and went through many sites, including this one. I have tried to take some codes which I thought I could alter to make it perform, but they just wouldn’t work for what I needed them to do.

I need a code that will automate a [COLOR=”Black”]“specific text message”[/COLOR] to change daily, and to schedule a [COLOR=”Black”]“different specific text message”[/COLOR] to appear each day. I need to be able to schedule each days [COLOR=”Black”]“texts”[/COLOR] at the very least 31 days in advance. In other words, I need to make an array [I](I think that’s what it is called)[/I] for the entire month:

[COLOR=”Black”]Day 1 “today’s text 1”
Day 2 “today’s text 2”
Day 3 “today’s text 3”[/COLOR]

” ” ” “
{through}
[COLOR=”Black”]Day 31 “today’s text 31”[/COLOR]

If were possible to make an “array” that would go six months out (or more) that would be very helpful! But the longest that I have seen is one month at a time, so that may be as long as they go, but I’m not sure. So I’m just asking.

On top of all of this, I need these changes to be performed at a [B][U]specific time of the day[/U][/B]. I would really like them to be preformed at sunset everyday, but I don’t think there is anyway to direct the code to look at like TimeandDate.com sunset times or such. So if I can at least choose a specific hour, [B]like 8:00 pm,[/B] that will work, I will just have to adjust this every once in a while.

[B]However,[/B] I don’t want it to change just at [B]8:00pm in my timezone[/B]. [B][U]I need it to change at 8:00pm according to the website viewers timezone.[/U][/B] Is there a way to make the code “look” at the users computer and “get their time” and use that to adjust what text is displayed?

In other words, I live in Indiana USA. If someone in Australia looked up the webpage on the [B]15th day[/B] of the month, [B]but[/B] it was [B]9:00pm [U]Their[/U] Time[/B]. The text I need to be displayed should be for [B][U]“Day 16”[/U][/B] from the array. [B][U]Is this Possible??!![/U][/B] I have searched for days now trying to find this info.

[B][SIZE=”4″]
Is there anyway to do all of this???? ? ??[/SIZE]
[/B]

I know its a lot to ask for, but if there is anyone who could steer me to a site or give me some help with what the code would need to be, I would [B]Sincerely Appreciate It[/B]!

[B][U]Thanks in Advance! [/U][/B][/COLOR][/FONT][/SIZE]

to post a comment
JavaScript

15 Comments(s)

Copy linkTweet thisAlerts:
@007JulienSep 18.2011 — It's easy to define a javascript string txs with the day's text in the month (or the year).

[code=html]<script type="text/javascript">
var txs="<p>Texte n&#176;1 with HTML tags</p>|<p>Texte n&#176;2 with other tags</p><ul><li>Item 1</li><li>Item 2</li></ul>|Texte n&#176; 3 ... |Texte n&#176; 4 ... etc.";
var tab=txs.split(/|/g);

var td=new Date(),yr=td.getFullYear(),jr=td.getDate(),mt=new Array();
// You take the jr-1 th element from tab if you work with month

// Or you compute the number of day before the month m (0 to 11 in javascript) in 2011
mt[0]=0;for (var i=1;i<12;i++) mt[i]=mt[i-1]+new Date(yr,i,0).getDate();
alert(mt);
var nbr=mt[td.getMonth()]+td.getDate();
alert("Today is the "+nbr+" th day in "+yr);
// It's 8.00 pm ?
if (td.getHours()<8) nbr--;
// to show tab[idx]
</script>[/code]


See this calendar for long string example
[code=html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="fr">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title>Calendrier</title>
<style type="text/css">
body {margin:0;padding:0;font:10px/13px "Courier New",Courier,monospace}
h1 {margin:20px;padding:0;font:16px/20px;text-align:center;}
a {text-decoration:none;color:#909;}
.mst {font-size:12px}
#cal {display:block;position:relative;margin:0 auto;width:840px;height:900px;overflow:hidden;}
.clc {display:block;position:absolute;top:0px;z-index:0;width:200px;padding:1px;background:#fff;}
</style>
</head>
<body>
<h1><a href="javascript:newAnn(-20)" title="Recul rapide - 20ans">&#171;&#171;</a>&nbsp;<a href="javascript:newAnn(-1)" title="Ann&#233;e pr&#233;c&#233;dente">&#171;</a>&nbsp;Calendrier <span id="ida"></span>&nbsp;<a href="javascript:newAnn(+1)" title="Ann&#233;e suivante">&#187;</a>&nbsp;<a href="javascript:newAnn(+20)" title="Avance rapide - 20 ans">&#187;&#187;</a>&nbsp;</h1>
<div id="cal"></div>
<script type="text/javascript">
var mos='Janvier|F&#233;vrier|Mars|Avril|Mai|Juin|Juillet|Ao&#251;t|Septembre|Octobre|Novembre|D&#233;cembre'.split(/|/g);
var tSt="Jour de l'an|St Basile|Ste Genevi&#232;ve|St Odilon|St Edouard|Ste M&#233;laine|St Raymond|St Lucien|Ste Alix|St Guillaume|St Paulin|Ste Tatiana|Ste Yvette|Ste Nina|St R&#233;mi|St Marcel|Ste Roseline|Ste Prisca|St Marius|St S&#233;bastien|Ste Agn&#232;s|St Vincent|St Barnard|St Fran&#231;ois de Sales|St Apollos|Ste Paule|Ste Ang&#232;le|St Thomas d'Aquin|St Gildas|Ste Martine|Ste Marcelle|Ste Ella|St Th&#233;ophane|St Blaise|Ste V&#233;ronique|Ste Agathe|St Gaston|Ste Eug&#233;nie|Ste Jacqueline|Ste Apolline|St Arnaud|ND de Lourdes|St F&#233;lix|Ste B&#233;atrice|St Valentin|St Claude|Ste Julienne|St Alexis|Ste Bernadette|St Gabin|Ste Aim&#233;e|St Damien|Ste Isabelle|St Lazare|St Modeste|St Rom&#233;o|St Nestor|Ste Honorine|St Romain|St Auguste|St Aubin|St Jaouen|St Gw&#233;nola|St Casimir|St Olive|Ste Colette|Ste F&#233;licit&#233;|St Jean de Dieu|Ste Fran&#231;oise|St Vivien|Ste Rosine|Ste Justine|St Rodrigue|Ste Mathilde|Ste Louise|Ste B&#233;n&#233;dicte|St Patrick|St Cyrille|St Joseph|St Herbert|Ste Cl&#233;mence|Ste L&#233;a|St Victorien|Ste Karine|Annonciation|Ste Lara|St Habib|St Gontran|Ste Gwladys|St Am&#233;d&#233;e|St Benjamin|St Hugues|Ste Sandrine|St Richard|St Isidore|Ste Ir&#232;ne|St Marcellin|St Jean-Baptiste|Ste Julie|St Gautier|St Fulbert|St Stanislas|St Jules|Ste Ida|St Maxime|St Paterne|St Beno&#238;t-Joseph|St Anicet|St Parfait|Ste Emma|Ste Odette|St Anselme|St Alexandre|St Georges|St Fid&#232;le|St Marc|Ste Alida|Ste Zita|Ste Val&#233;rie|Ste Catherine|St Robert|St Jeremie|St Boris|St Philippe|St Sylvain|Ste Judith|Ste Prudence|Ste Gis&#232;le|St D&#233;sir&#233;|Ste Pac&#244;me|Ste Solange|Ste Estelle|St Achille|Ste Rolande|St Matthias|Ste Denise|St Honor&#233;|St Pascal|St Eric|St Yves|St Bernardin|St Constantin|St Emile|St Didier|St Donatien|Ste Sophie|St B&#233;renger|St Augustin|St Germain|St Aymard|St Ferdinand|Ste Perrette|St Justin|Ste Blandine|St Kevin|Ste Clotilde|St Igor|St Norbert|St Gilbert|St M&#233;dard|Ste Diane|Ste Trinit&#233;|St Barnab&#233;|St Guy|St Antoine|St Elis&#233;e|Ste Germaine|St R&#233;gis|St Herv&#233;|St L&#233;once|St Romuald|St Silv&#232;re|St Rodolphe|St Alban|Ste Audrey|St Yann|St Prosper|St Anthelme|St Fernand|St Ir&#233;n&#233;e|St Pierre/St Paul|St Martial|St Thierry|St Martinien|St Thomas|St Florent|St Antoine|Ste Mariette|St Eliane|St Thibaud|Ste Amandine|St Ulric|St Beno&#238;t|St Olivier|St Henri/St Jo&#235;l|St Camille/F&#234;te Nationale|St Donald|Ste Carmen|Ste Charlotte|St Fr&#233;d&#233;ric|St Ars&#232;ne|Ste Marina|St Victor|Ste Marie-Madeleine|Ste Brigitte|Ste Christine|St Jacques|Ste Anne|Ste Nathalie|St Samson|Ste Marthe|Ste Juliette|St Ignace|St Alphonse|St Julien|Ste Lydie|St Jean-Marie|St Abel|St Octavien|St Ga&#233;tan|St Dominique|St Amour|St Laurent|Ste Claire|Ste Clarisse|St Hippolyte|St Evrard|Ste Marie/Assomption|St Armel|St Hyacinthe|Ste H&#233;l&#232;ne|St Jean-Eudes|St Bernard|St Christophe|St Fabrice|Ste Rose|St Barth&#233;l&#233;my|St Louis|Ste Natacha|Ste Monique|St Augustin|Ste Sabine|St Fiacre|St Aristide|St Gilles|Ste Ingrid|St Gr&#233;goire|Ste Rosalie|Ste Ra&#239;ssa|St Bertrand|Ste Reine|St Adrien|St Alain|Ste In&#232;s|St Adelphe|St Apollinaire|St Aim&#233;|St Materne|St Roland|Ste Edith|St Renaud|Ste Nad&#232;ge|Ste Emilie|St Davy|St Matthieu|St Maurice|St Constant|Ste Th&#232;cle|St Hermann|St C&#244;me/St Damien|St Vincent de Paul|St Venceslas|Sts Michel|St J&#233;r&#244;me|Ste Th&#233;r&#232;se|St L&#233;ger|St G&#233;rard|St Fran&#231;ois|Ste Fleur|St Bruno|St Serge|Ste P&#233;lagie|St Denis|St Ghislain|St Firmin|St Wilfrid|St G&#233;raud|St Juste|Ste Th&#233;r&#232;se|Ste Edwige|St Baudouin|St Luc|St Ren&#233; Goupil|Ste Adeline|Ste C&#233;line|Ste Elodie|St Jean de Capistran|St Florentin|St Cr&#233;pin|St Dimitri|Ste Emeline|St Simon|St Narcisse|Ste Bienvenue|St Quentin|Toussaint|D&#233;funts|St Hubert|St Charles|Ste Sylvie|Ste Bertille|Ste Carine|St Geoffroy|St Th&#233;odore|St L&#233;on|St Martin|St Christian|St Brice|St Sidoine|St Albert|Ste Marguerite|Ste Elisabeth|Ste Aude|St Tanguy|St Edmond|Pr&#233;sentation de Marie|Ste C&#233;cile|St Cl&#233;ment|Ste Flora|Ste Catherine|Ste Delphine|St S&#233;verin|St Jacques de la Marche|St Saturnin|St Andr&#233;|Ste Florence|Ste Viviane|St Xavier|Ste Barbara|St G&#233;rald|St Nicolas|St Ambroise|Ste Frida|St Pierre Fourier|St Romaric|St Daniel|Ste Chantal|St Lucie|Ste Odile|Ste Ninon|Ste Alice|St Ga&#235;l|St Gatien|St Urbain|St Th&#233;ophile|St Pierre Canisius|Ste Fran&#231;oise-Xavi&#232;re|St Armand|Ste Ad&#232;le|No&#235;l|St Etienne|St Jean|St Gaspard|St David|St Roger|St Sylvestre".split(/|/g);
function edtCal(a){
var chn='',ms=-1,bs=0,s=Math.floor(a/100),pl=(15-Math.floor(s/4)+s-Math.floor(((s<<3)+13)/25)+19*(a&#37;19))%30,pj,pq,cn,pq,as,pn;
if (pl==28) if (10<(a%19)) pl--;else pl++;
pj=pl;if (pl!=29 || new Date(a,2,pl).getDay()) pj=pl-new Date(a,2,pl).getDay()+7;
cn=new Date(a,2,pj-25).valueOf();pq=new Date(a,2,pj+21).valueOf();
as=new Date(a,2,pj+60).valueOf();pn=new Date(a,2,pj+70).valueOf();
for (i=1;;i++){cd=new Date(a,0,i);
if (cd.getFullYear()!=a) break;
if (cd.getMonth()!=ms) {ms=cd.getMonth();
if (chn) chn+='</div>';
chn+='<div class="clc" style="left:'+((140*ms)%840)+'px;top:'+((140*ms<820)?0:450)+'px;z-index:'+ms+'" onmouseover="this.style.zIndex=13" onmouseout="this.style.zIndex='+ms+'"><b class="mst">'+mos[ms]+'</b><hr>'}
if (i==60 && cd.getMonth()==2) bs++;
y=z='';if (!cd.getDay()) y='<u>';z='</u>';
if (cd.valueOf()==cn) chn+='Me '+cd.getDate()+' <b>Cendres *</b><br>';
else if (cd.valueOf()==pq) chn+='<u>Di '+cd.getDate()+' <b>P&#226;ques *</b></u><br>';
else if (cd.valueOf()==as) chn+='Je '+cd.getDate()+' <b>Ascension *</b><br>';
else if (cd.valueOf()==pn) chn+='<u>Di '+cd.getDate()+' <b>Pentec&#244;te *</b></u><br>';
else chn+=y+"DiLuMaMeJeVeSa".substr(2*cd.getDay(),2)+' '+cd.getDate()+' '+tSt[i-1+bs]+z+'<br>';}
chn+='</div>';
document.getElementById('ida').innerHTML=a;
document.getElementById('cal').innerHTML=chn;
}
edtCal(new Date().getFullYear());
function newAnn(d){var a=document.getElementById('ida').innerHTML;edtCal(parseInt(a)+d);}
</script>
</body>
</html>[/code]
Copy linkTweet thisAlerts:
@JMRKERSep 18.2011 — Here is a sample of what you might try.

Notes:

1. You can modify the 'quotes' array contents.

2. The 'quotes' array could be an external JS file.

3. The 'quotes' array contents could be put into individual files with a slight logic test modification.

4. The "new Date()" should get the local date and time for any particular area.


Currently it changes at 6pm but could be made to change hourly or other time increments.

There are other modifications you could make using GMT an UTC time, if needed.

5. Remove the 'random-ness' button and logic as they are included only for testing or to add variety.

6. You could spice the display up a bit more with additional CSS changes

7. The displays can be modified for "Quote of the Day", "Quote of the Year"

or any other time period based upon the needs and the number of quotes available.

<i>
</i>&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt; Quotes &lt;/title&gt;

&lt;script type="text/javascript"&gt;
// For: http://www.webdeveloper.com/forum/showthread.php?t=251318

// store the quotations in one multiple array
// or as external JS file
// or as single JS files, if lengthly, with filenames like QODday.js (QOD1.js, QOD2.js, ..., QOD31.js)
// or (suggestion based upon user needs)

quotes = [
["It's not easy being green.","Kermit the Frog"],
["I shall return.","General Douglas MacArthur"],
["War is hell!","General William Tecumseh Sherman"],
["&lt;b&gt;Never, never, never ... Give up!&lt;/b&gt;","Winston Churchill"],
["The buck stops here!","President Harry S. Truman"],
["You never get too old to learn a new way of being stupid.","Me"],
["&lt;em&gt;Rumsey's Rule of the Lab:&lt;/em&gt;&lt;br&gt;"
+" Never go home dumber than you came.","Rumsey"],
["Sadly, I am no longer young enough to know everything.."
+"&lt;br&gt;&lt;font size='-1'&gt;With thanks to Philip M.&lt;/font&gt;","Old Pedant"],
["The quick red fox jumps over the lazy brown dog!",""], // Note: no author attribute

// continue on for total of 31 entrys for each day of the month
// could also be adapted for 365+ days of the year
// or any number of quotes between with a modulo test
["Now is the time for all good men"
+" to come to the aid of their country.",
"Anonymous"] // Note: No comma after final entry
];

function DisplayQuote(index) {
var str = '';
str += '&lt;DL&gt;n&lt;DT style="color:blue"&gt;"' + quotes[index][0] + '"n';
str += "&lt;DD style='color:orange'&gt;-- " + quotes[index][1] + "n&lt;/DL&gt;n";
document.getElementById('QuoteOfTheDay').innerHTML = str;
}

function TodayQuote() {
var now = new Date(); // get current date and time
var index = now.getDate(); // get current month date
if (now.getHours() &gt;= 18) { index++; } // check if 6pm or later

// remove next line if quotes.length is same as number of days in month (or year)
index = (index &amp;#37; quotes.length);
DisplayQuote(index);
}

function RandomQuote() {
var index = Math.floor(Math.random() * quotes.length); // calculate a random index
DisplayQuote(index);
}

//display the quotation
window.onload = function() { RandomQuote(); }

&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="QuoteOfTheDay"&gt;&lt;/div&gt;

&lt;p&gt;&lt;button onclick="RandomQuote()"&gt;Test of randomness&lt;/button&gt;
&lt;button onclick="TodayQuote()"&gt;Today's Quote&lt;/button&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@commanderauthorSep 18.2011 — It's easy to define a javascript string txs with the day's text in the month (or the year).

[code=html]<script type="text/javascript">
var txs="<p>Texte n°1 with HTML tags</p>|<p>Texte n°2 with other tags</p><ul><li>Item 1</li><li>Item 2</li></ul>|Texte n° 3 ... |Texte n° 4 ... etc.";
var tab=txs.split(/|/g);

var td=new Date(),yr=td.getFullYear(),jr=td.getDate(),mt=new Array();
// You take the jr-1 th element from tab if you work with month

// Or you compute the number of day before the month m (0 to 11 in javascript) in 2011
mt[0]=0;for (var i=1;i<12;i++) mt[i]=mt[i-1]+new Date(yr,i,0).getDate();
alert(mt);
var nbr=mt[td.getMonth()]+td.getDate();
alert("Today is the "+nbr+" th day in "+yr);
// It's 8.00 pm ?
if (td.getHours()<8) nbr--;
// to show tab[idx]
</script>[/code]


[/QUOTE]


[COLOR="Navy"]Thanks for the reply and help Julien! I tried your first code out on a test run, but it came back with a ["Syntax Error" Line 137 Character 1 Code 0] Since this seems to have the ability to change the text at 8.00pm I think this might work. The 2nd code seems more complicated that I understand. This is something that I have to edit every month, or if possible every few months.



I meant to insert this the code that I was working with into my original post, but it was late and I forgot to. I know it might be an "older" code, but it's simple to me. However it does not change at specific time, and I have tried to find examples that does this, and insert the lines of code needed to get it to work. But it always came back with an error, or it just didn't change.



So anyway here is the code that I was working with, not that it has to be this code, it's just a little more simple to me, if it would change at a specific time of day according to the views computer time. [/COLOR]


[code=html]<table border="0" width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="0">
<tr><td width="100%">

<script>
<!--

var today_obj=new Date()
var today_date=today_obj.getDate()

var tips=new Array()
//Configure the below variable to contain the "header" of the tip
var tiptitle=''

//Configure the below array to hold the 31 possible tips of the month
tips[1]='Tip 1 goes here'
tips[2]='Tip 2 goes here'
tips[3]='Tip 3 goes here'
tips[4]='Tip 4 goes here'
tips[5]='Tip 5 goes here'
tips[6]='Tip 6 goes here'
tips[7]='Tip 7 goes here'
tips[8]='Tip 8 goes here'
tips[9]='Tip 9 goes here'
tips[10]='Tip 10 goes here'
tips[11]='Tip 11 goes here'
tips[12]='Tip 12 goes here'
tips[13]='Tip 13 goes here'
tips[14]='Tip 14 goes here'
tips[15]='Tip 15 goes here'
tips[16]='Tip 16 goes here'
tips[17]='Tip 17 goes here'
tips[18]='Tip 18 goes here'
tips[19]='Tip 19 goes here'
tips[20]='Tip 20 goes here'
tips[21]='Tip 21 goes here'
tips[22]='Tip 22 goes here'
tips[23]='Tip 23 goes here'
tips[24]='Tip 24 goes here'
tips[25]='Tip 25 goes here'
tips[26]='Tip 26 goes here'
tips[27]='Tip 27 goes here'
tips[28]='Tip 28 goes here'
tips[29]='Tip 29 goes here'
tips[30]='Tip 30 goes here'
tips[31]='Tip 31 goes here'

document.write(tiptitle)
document.write(tips[today_date])

//-->
</script>

</td></tr></table>[/code]
Copy linkTweet thisAlerts:
@commanderauthorSep 18.2011 — Here is a sample of what you might try.

[/QUOTE]


Hi JMRKER, Thanks for the reply and code help! I tried your code for a test run also, and the buttons were displayed. So I clicked on one, and it comes up with the same ["Syntax Error" Line 137 Character 1 Code 0] that Julien's code did for some reason. I don't need the buttons anyway, so I went and removed that line of code, but when I retested, no text was displayed and the same error message appeared.

I'm starting to think this error has something to do with a code incompatibility with Homestead...? Although I haven't seen it before now, so maybe not.

I posted the code I have been working with in my previous post. It does work in displaying the text, but I can't get it to change at the correct time of day according to the site viewers computer. Also I don't see a way of extending it beyond the 31 days, so this would have to be changed monthly, which I could deal with as long as I can get it to work correctly... and not forget to update it ?
Copy linkTweet thisAlerts:
@007JulienSep 18.2011 — A simple script
[code=html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="fr">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title>Untitled</title>
<style type="text/css">
</style>
</head>
<body>
<div id="pge"></div>
<script type="text/javascript">
var i,dailyTxt=[],mt=[];
// DailyTxt an artificial array with 365 days in 2011 (from 1 to 365)
// (the first day correspond to the december, 31 2010)
// The real array is buil with PHP as javascript file to define a string and an equivalent tab by split)
dailyTxt[0]="Text for the december, 31st day";
for (i=1;i<=365;i++) dailyTxt[i]="Text for the "+i+((i%10==1 && i!=11)?"st":(i%10==2 && i!=12)?"nd":(i%10==3 && i!=13)?"rd":"th")+" day";
// A method to show the daily text
var td=new Date(),yr=td.getFullYear(),mn=td.getMonth(),jr=td.getDate();
var precedingDays=0;
for (var i=0;i<mn;i++) {precedingDays+=new Date(yr,i,0).getDate();}
var nbr=precedingDays+jr;
if (td.getHours()<8) {nbr--;}
document.getElementById('pge').innerHTML='<p> To day is '+td.toLocaleString()+'</p>';
document.getElementById('pge').innerHTML+='<p>The daily text is <b>'+dailyTxt[nbr]+'</b></p>';
</script>
</body>
</html>[/code]
Copy linkTweet thisAlerts:
@JMRKERSep 18.2011 — Comments to your response in [COLOR="Red"]RED[/COLOR] below:
Hi JMRKER, Thanks for the reply and code help! I tried your code for a test run also, and the buttons were displayed. So I clicked on one, and it comes up with the same ["Syntax Error" Line 137 Character 1 Code 0] that Julien's code did for some reason. I don't need the buttons anyway, so I went and removed that line of code, but when I retested, no text was displayed and the same error message appeared.

[COLOR="red"]The code I provided was tested in FF, but should work fine in MSIE.

Since it works fine, without your modifications, it's probably you.

Do you have a link to your actual code. What you posted in #1 and #4 are not the same.

[/COLOR]


I'm starting to think this error has something to do with a code incompatibility with Homestead...? Although I haven't seen it before now, so maybe not.

[COLOR="Red"]Post the like to your site so we can see the errors directly.

[/COLOR]


I posted the code I have been working with in my previous post. It does work in displaying the text, but I can't get it to change at the correct time of day according to the site viewers computer.

Also I don't see a way of extending it beyond the 31 days, so this would have to be changed monthly, which I could deal with as long as I can get it to work correctly... and not forget to update it ?

[COLOR="red"]It is very easy to extend beyond 31 days (any amount to be precise)

but I'll show you how it is done when you decide on the amount and provide

some of your text examples either in the array format or as individual JS files.

[/COLOR]

[/QUOTE]
Copy linkTweet thisAlerts:
@commanderauthorSep 19.2011 — Ok JMRKER, I just created a test text page (so as not to mess with the home page) and posted the codes there. Here is the link: http://www.yhrim.com/text.html

I haven't modified your codes in anyway, yet. I just copied and pasted them to see first if they would work with homestead. I still think it is something to do with how the homestead program is handling the code. Haven't had this kind of problem with code before though with homestead. So I'm not sure. The only one that displays any text is my original "old style" code.
Copy linkTweet thisAlerts:
@FairviewSep 19.2011 — Try this instead:

[CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>None</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">

function init(){

var nDiv = document.getElementsByTagName('div');
for (i=0; i<nDiv.length; i++)
{
if (nDiv[i].className == "message_display")
{
var nItems = nDiv[i].getElementsByTagName('ul')[0].getElementsByTagName('li');
for (n=0; n<nItems.length; n++)
{
nItems[n].style.display = "none";
}
}
}
var today = new Date();
var EOM = new Date(today.getFullYear(),today.getMonth()+1,today.getDate()-today.getDate()).getDate();
var nIndex = today.getHours() >= 20
? today.getDate() == EOM
? 0
: today.getDate()
: today.getDate() - 1;
nItems[nIndex].style.display = "";
}

navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false);

</script>
<style type="text/css">

body {background-color: #fffacd; margin-top: 60px;}

.message_display {width: 500px; border: 1px solid black; text-align: center;
font-family: tahoma; font-size: 12pt; background-color: #eee8aa;
font-weight: bold; padding: 3px; margin: auto; cursor: default;}

.message_display ul {list-style: none; margin: 0px; padding: 0px;}

</style>
</head>
<body>

<div class="message_display">
<ul>
<li>This is the 1st message</li>
<li>This is the 2nd message</li>
<li>This is the 3rd message</li>
<li>This is the 4th message</li>
<li>This is the 5th message</li>
<li>This is the 6th message</li>
<li>This is the 7th message</li>
<li>This is the 8th message</li>
<li>This is the 9th message</li>
<li>This is the 10th message</li>
<li>This is the 11th message</li>
<li>This is the 12th message</li>
<li>This is the 13th message</li>
<li>This is the 14th message</li>
<li>This is the 15th message</li>
<li>This is the 16th message</li>
<li>This is the 17th message</li>
<li>This is the 18th message</li>
<li>This is the 19th message</li>
<li>This is the 20th message</li>
<li>This is the 21st message</li>
<li>This is the 22nd message</li>
<li>This is the 23rd message</li>
<li>This is the 24th message</li>
<li>This is the 25th message</li>
<li>This is the 26th message</li>
<li>This is the 27th message</li>
<li>This is the 28th message</li>
<li>This is the 29th message</li>
<li>This is the 30th message</li>
<li>This is the 31st message</li>
</ul>
</div>

</body>
</html>
[/CODE]
Copy linkTweet thisAlerts:
@JMRKERSep 19.2011 — Ok JMRKER, I just created a test text page (so as not to mess with the home page) and posted the codes there. Here is the link: http://www.yhrim.com/text.html

I haven't modified your codes in anyway, yet. I just copied and pasted them to see first if they would work with homestead. I still think it is something to do with how the homestead program is handling the code. Haven't had this kind of problem with code before though with homestead. So I'm not sure. The only one that displays any text is my original "old style" code.[/QUOTE]


Sorry, I don't see any of my recommended code in that link. ?

I'm beginning to believe you have too many cooks for this broth. :eek:

Try using only one solution per test file. :rolleyes:
Copy linkTweet thisAlerts:
@commanderauthorSep 20.2011 — Sorry, I don't see any of my recommended code in that link. ?

I'm beginning to believe you have too many cooks for this broth. :eek:

Try using only one solution per test file. :rolleyes:[/QUOTE]


Too Slow JMRKER :-) They were there, but then I took them back off as they were not displaying. What is there now is Fairviews Code (By the way Thanks Fairview). Their code does display, but it also changes the whole pages background to tan.. ? I still think this is a problem with Homestead not fully "agreeing" with the code or something. Because as you said JMRKER, the other codes should have worked.

I'm going through it to see how I can fix the background being changed by this code, and to see if I can modify it to work with what I need.... As soon as I have some free time anyway. I've just been really busy the past few days, maybe I'll get back on this in a day or two.

But I do want to Thank Everyone who has tried to help so far. It is much appreciated!
Copy linkTweet thisAlerts:
@commanderauthorSep 20.2011 — Well fixed the back ground and took out the border/box around the text. I'll work on it some more maybe tomorrow night. Gotta catch some sleep in the mean time.

~ Peace
Copy linkTweet thisAlerts:
@JMRKERSep 20.2011 — Too Slow JMRKER :-) They were there, but then I took them back off as they were not displaying. What is there now is Fairviews Code (By the way Thanks Fairview). Their code does display, but it also changes the whole pages background to tan.. ? I still think this is a problem with Homestead not fully "agreeing" with the code or something. Because as you said JMRKER, the other codes should have worked.

...[/QUOTE]


No problems on my side.


You get my time and effort that you pay for as I do have a "real" job. ?
Copy linkTweet thisAlerts:
@commanderauthorSep 21.2011 — Hi, its me again. Sorry to have to bug you guys all the time. But I think I have a code that will work, but it still needs a bit of tweaking.

The code that Fairview posted (Thanks Again Fairview!) seems to agree with the Homestead program. I don't get any error messages, and it does display. However, there is a couple of things I need to know.

[B]#1[/B] On the "message list" is there a way to number the days in the code, so I know which line is what day?

For example the code currently is:

[code=html]
<li>Todays message</li>
<li>Todays message</li>
<li>Todays message</li>
<li>Todays message</li>[/code]


All lines look the same.

In Each line, the <[B]li[/B]> is all the same. So be sure of what day I am changing the message for, I would have to count down how many lines I am from the top, and change that days message. Otherwise I might accidentally change the message for a different day, since all lines look the same.

To make this much easier is there a way to change the <li> in each line (or to add text to number each line) to reflect what day of the month that line is for?

Something Like:

[code=html]<day-1>Todays message</li>
<day-2>Todays message</li>
<day-3>Todays message</li>
<day-4>Todays message</li>[/code]


Or like:

[code=html]Day 1 <li>Todays message</li>
Day 2 <li>Todays message</li>
Day 3 <li>Todays message</li>
Day 4 <li>Todays message</li>[/code]




[B]#2[/B] One little thing that doesn't really affect the codes workability, but is just really annoying. When the page is first loading, it displays the entire months message list, all 31 messages, going down the screen in a column. Then after a moment or two (depending upon your internet speed), it updates and just shows the message for today. Is there anyway to correct this, so the entire list is not seen? And it only displays "todays message" when it loads?

You can see what I'm talking about here on the test page, as I have it posted using the updated code: http://www.yhrim.com/text.html


Thanks Again Everyone!
Copy linkTweet thisAlerts:
@clueless75Sep 05.2015 — Fairview,

This was most helpful. I modified it to day of the year as follows:


script type="text/javascript">

function init(){

var nDiv = document.getElementsByTagName('div');
for (i=0; i<nDiv.length; i++)
{
if (nDiv[i].className == "message_display")
{
var nItems = nDiv[i].getElementsByTagName('ul')[0].getElementsByTagName('li');
for (n=0; n<nItems.length; n++)
{
nItems[n].style.display = "none";
}
}
}
var now = new Date();
var start = new Date(now.getFullYear(), 0, 0);
var diff = now - start;
var oneDay = 1000 * 60 * 60 * 24;
var day = Math.floor(diff / oneDay);
nItems[day].style.display = "";
}

navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false);


</script>


Seems to work ok. Problems is I need date specific as the application is "on this day ..." and leap years change the absolute day. So I figured I'd build the array with ULs for each month and LIs for the days. Go to the getMonth() UL and then spin to the getDay() LI. For the life of me I cannot get it to work. Hence the username which is an apt description of my coding skills. Any suggestions welcome.
Copy linkTweet thisAlerts:
@Codex_NGSep 07.2015 — Leap year happens every 0, 4, 8, 12, 16, in that sequence, if we look at the 20+ it would continue, 20, 24, 28, 32, 36 etc next sequence 40, 44, 48, 52, 56, see the pattern?

This code returns on my computer
<i>
</i>// Wed Dec 31 2014 00:00:00 GMT-0500 (Eastern Daylight Time)
new Date(now.getFullYear(), 0, 0);
// based on your formula and the current date it returns 250


Since its 2015 hehe, you need to add +1 to now.getFullYear()
<i>
</i>var now = new Date();
// added + 1 to now.getFullYear()
var start = new Date(now.getFullYear() + 1, 0, 0);
var diff = start - now; // this has been reversed or it will a negative number
var oneDay = 1000 * 60 * 60 * 24;
var day = Math.floor(diff / oneDay); // day now returns 114
×

Success!

Help @commander spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...