www.webdeveloper.com
Results 1 to 14 of 14

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

  1. #1
    Join Date
    Sep 2011
    Location
    Indiana USA
    Posts
    7

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

    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 "specific text message" to change daily, and to schedule a "different specific text message" to appear each day. I need to be able to schedule each days "texts" at the very least 31 days in advance. In other words, I need to make an array (I think that's what it is called) for the entire month:

    Day 1 "today's text 1"
    Day 2 "today's text 2"
    Day 3 "today's text 3"

    " " " "
    {through}
    Day 31 "today's text 31"

    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 specific time of the day. 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, like 8:00 pm, that will work, I will just have to adjust this every once in a while.

    However, I don't want it to change just at 8:00pm in my timezone. I need it to change at 8:00pm according to the website viewers timezone. 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 15th day of the month, but it was 9:00pm Their Time. The text I need to be displayed should be for "Day 16" from the array. Is this Possible??!! I have searched for days now trying to find this info.


    Is there anyway to do all of this????

    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 Sincerely Appreciate It!

    Thanks in Advance!

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,252
    It's easy to define a javascript string txs with the day's text in the month (or the year).

    HTML Code:
    <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>
    See this calendar for long string example
    HTML Code:
    <!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>

  3. #3
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,259

    Lightbulb Something to consider ...

    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.

    Code:
    <!DOCTYPE HTML>
    <html>
    <head>
    <title> Quotes </title>
    
    <script type="text/javascript">
    // 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"],
      ["<b>Never, never, never ... Give up!</b>","Winston Churchill"],
      ["The buck stops here!","President Harry S. Truman"],
      ["You never get too old to learn a new way of being stupid.","Me"],
      ["<em>Rumsey's Rule of the Lab:</em><br>"
       +" Never go home dumber than you came.","Rumsey"],
      ["Sadly, I am no longer young enough to know everything.."
       +"<br><font size='-1'>With thanks to Philip M.</font>","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 += '<DL>\n<DT style="color:blue">"' + quotes[index][0] + '"\n';
          str += "<DD style='color:orange'>-- " + quotes[index][1] + "\n</DL>\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() >= 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 &#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(); }
    
    </script>
    </head>
    <body>
    <div id="QuoteOfTheDay"></div>
    
    <p><button onclick="RandomQuote()">Test of randomness</button>
    <button onclick="TodayQuote()">Today's Quote</button>
    </body>
    </html>
    Last edited by JMRKER; 09-18-2011 at 10:01 AM. Reason: 007Julien types faster than me!

  4. #4
    Join Date
    Sep 2011
    Location
    Indiana USA
    Posts
    7
    Quote Originally Posted by 007Julien View Post
    It's easy to define a javascript string txs with the day's text in the month (or the year).

    HTML Code:
    <script type="text/javascript">
    var txs="<p>Texte n1 with HTML tags</p>|<p>Texte n2 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>
    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.


    HTML Code:
    <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>

  5. #5
    Join Date
    Sep 2011
    Location
    Indiana USA
    Posts
    7
    Quote Originally Posted by JMRKER View Post
    Here is a sample of what you might try.
    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

  6. #6
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,252
    A simple script
    HTML Code:
    <!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>

  7. #7
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,259

    Lightbulb

    Comments to your response in RED below:
    Quote Originally Posted by commander View Post
    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.

    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.


    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.
    Post the like to your site so we can see the errors directly.

    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

    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.

  8. #8
    Join Date
    Sep 2011
    Location
    Indiana USA
    Posts
    7
    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.

  9. #9
    Join Date
    Jun 2011
    Posts
    34
    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>

  10. #10
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,259

    Question

    Quote Originally Posted by commander View Post
    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.
    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.
    Try using only one solution per test file.

  11. #11
    Join Date
    Sep 2011
    Location
    Indiana USA
    Posts
    7
    Quote Originally Posted by JMRKER View Post
    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.
    Try using only one solution per test file.
    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!

  12. #12
    Join Date
    Sep 2011
    Location
    Indiana USA
    Posts
    7
    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

  13. #13
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,259

    resolved

    Quote Originally Posted by commander View Post
    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.
    ...
    No problems on my side.
    You get my time and effort that you pay for as I do have a "real" job.

  14. #14
    Join Date
    Sep 2011
    Location
    Indiana USA
    Posts
    7

    Almost There.... I Think

    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.

    #1 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:

    HTML Code:
    <li>Todays message</li>
    <li>Todays message</li>
    <li>Todays message</li>
    <li>Todays message</li>
    All lines look the same.
    In Each line, the <li> 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:

    HTML Code:
    <day-1>Todays message</li>
    <day-2>Todays message</li>
    <day-3>Todays message</li>
    <day-4>Todays message</li>
    Or like:

    HTML Code:
    Day 1 <li>Todays message</li>
    Day 2 <li>Todays message</li>
    Day 3 <li>Todays message</li>
    Day 4 <li>Todays message</li>


    #2 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!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles