Reputation: 808
When the page loads i need the application to load a javascript function that displays a part of the url. Ive can get as far as to display the dates i want at the right times by using a button and alert. But what i want to do is to have the date display in a span tag by calling the function.
my js function for getting the date.
function getURL(){
var url = document.location.href;
urlSplit = url.split("/timesheet");
if(urlSplit[1]== "")
{
var d = new Date();
//return d.toString;
alert(d);
}
else
{
week = url.split("week_commencing=");
//return week[1];
alert(week[1]);
}
}
my span tag
<b><center>Hours for Week commencing: <span id="startDate"></span></center></b><br />
Im sure this is really simple but its proving to be extremely tricky. Can anyone point me in the right direction?
Upvotes: 0
Views: 199
Reputation: 2123
Just call document.getElementById("startDate").innerHTML = date in place of the alert.
regards
Upvotes: 1