I am new to Javascript; just reading the tutorial. Can I use Javascript to determine the month and then take actions in html based on what month it is? If yes, how?
Skip to the section in the tutorial that covers the Date object.
You can get the current date with javascript, and there is a getMonth() method that returns an integer from 0 (January) to 11 (december).
Thank you very much, mrhoo. When a month is displayed on the calendar, I want to take actions based on what month is displayed, not based on what the current month is. For example, when April is displayed, I want the user to see all of April's events, etc. Is there a way to do this?
monthName is one of the parameters used to determine monthYear. I am thinking that I can write a JS function, setActivity(), to display activities based on what monthName is. However, I'm not sure how to get the activities in the body section of the html code.
Thanks for the link. It was very helpful. In practicing writing functions and calling them, I wrote this function.
function writeActivities()
{
document.write("all of jan");
}//writeActivities()
I call it with writeActivities(); and everything worked as expected.
For practicing functions with parameters, I wrote this function.
function writeActivities(mnthName)
{
var y = mnthName;
if (y=="JAN")
{
document.write("all of jan");
}
document.write("<br>the rest");
}//writeActivities()
When I called it with writeActivities(mnthName);, nothing happened until I put parens around mnthName in the call, writeActivities("mnthName"); .
Do you have to use parens when you are passing a variable when calling a function just as when you pass a string of text?
Bookmarks