Copy link to clipboard
Copied
Building my first phone app using Dreamweaver CC, Visual Studio 2015, and hopefully PhoneGap to pull it all together. Coding with HTML5, CSS, and Javascript.
Goal: create a daily devotional app. Problem: How to have specific text show beneath "today's date"?
Any help and pointers towards tutorials would be much appreciated.
Copy link to clipboard
Copied
A basic "Quote of the Day" JavaScript.
// JavaScript Document
//**********************
// QUOTE OF THE DAY SCRIPT: Add 31 quotes or inspirational messages to the array below. Each day a new quote will be displayed.
//***********************
var date = new Date().getDate();
var quote = new Array();
quote[1] = "The mind is everything. What we think we become. --Buddha";
quote[2] = "Adults are just outdated children. --Dr. Seuss";
quote[3] = "The secret of getting ahead is getting started. --Mark Twain";
etc...
Nancy O.
Copy link to clipboard
Copied
Thank you for responding. Is there a way to pull automatically from a preset list for each day and not just pull randomly? So for example July 4th every year it will be the same inspirational message.
Copy link to clipboard
Copied
Also, I already have id's on each message.
Copy link to clipboard
Copied
The script above is not random.
Each day of the month 1-31 contains a quote. If the current date is 23rd, you'll see the quote corresponding to the 23rd.
Nancy O.
Copy link to clipboard
Copied
I'm still working this out, Nancy. Thank you so much for the help. I'm a javascript newbie trying to wear the big kid's pants.
Copy link to clipboard
Copied
OK. Don't forget to wrap your JavaScript inside <script> </script>
tags.
<script>
// QUOTE OF THE DAY SCRIPT: Add 31 quotes or inspirational messages to the array below. Each day a new quote will be displayed.
//***********************
var date = new Date().getDate();
var quote = new Array();
quote[1] = "The mind is everything. What we think we become. --Buddha";
quote[2] = "Adults are just outdated children. --Dr. Seuss";
quote[3] = "The secret of getting ahead is getting started. --Mark Twain";
quote[31] = "This is the last quote. No semi-colon after this one."
var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();
</script>
Nancy O.
Copy link to clipboard
Copied
Okay. Thank you, Nancy. Just having trouble tying each new quote to the right date. Getting closer though, I know. Thank you!