random - JavaScript Quotes of the day with assigned Authors -


it looks keeps locked specific day , doesn't change when refresh, want to add authors array. such as:

quote // author

with authors displaying on next line, randomizing quote order.

any tips?

<script type="text/javascript">  var quote = new array();  quote[0] = 'quote 1 lorem ipsum dolor sit amet, consectetuer adipiscing     elit.';  quote[1] = 'quote 2 nullam commodo venenatis elit. in aliquam.';  quote[2] = 'quote 3 sed vitae risus ac urna pharetra tristique.';  quote[3] = 'quote 4 maecenas id mi quis nisl porta sodales.';  quote[4] = 'quote 5 fusce lorem velit, tempor sit amet, luctus nec, suscipit at, velit';  quote[5] = 'quote 6 ut pellentesque mauris non justo. in varius.';  quote[6] = 'quote 7 phasellus non urna dignissim nisl mollis consectetuer.';  var qlen = quote.length;  var firstdate = new date(2005,0,1);//start date (yyyy,m,d) - m=0=january, m=1=february  var today = new date();//today  var dif = math.floor((today-firstdate)/1000/60/60/24);//difference in days  while(dif>=qlen){//calculate index of quote of day  dif=dif-qlen;//restart array index if difference greater array's length  }  var todayquote = quote[dif];//the quote of day  onload = function(){document.getelementbyid('q').firstchild.data = todayquote}  </script>  </head>  <body>  <div id='q'>&nbsp;</div>  </body>  </html>  

i know late answer.

<script type="text/javascript">           var quote = new array();          quote[0] = ['quote 1 lorem ipsum dolor sit amet, consectetuer adipiscing     elit.',"some text"];          quote[1] = ['quote 2 lorem ipsum dolor sit amet',"some text"];           var qlen = quote.length;          var firstdate = new date(2005,0,1);//start date (yyyy,m,d) - m=0=january, m=1=february          var today = new date();//today          var dif = math.floor((today-firstdate)/1000/60/60/24);//difference in days          while(dif>=qlen){//calculate index of quote of day              dif=dif-qlen;//restart array index if difference greater array's length          }           var todayquote = quote[dif];          onload = function(){document.getelementbyid('q').firstchild.data = todayquote}      </script>  

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -