Reputation: 1
I'm trying to make a web application that updates a list every day, but I'm trying to link the new day/date to a different PHP page that I have made.
function myFunction() {
var d = new Date();
var weekday = new Array(7);
weekday[0] = <?php include'sunday.php';?>;
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
var n = weekday[d.getday()] document.getElementById("subject").innerHTML = n;
}
My result that I'm trying to achieve is to have a new day link to a separate web page
I have come across another problem, I cannot or well don't know how to get the information from the other file and print it out onto the main file.
code from both files :
index -
<script>
function date() {
var d = new Date();
var weekday = new Array(7);
weekday[0] = <?php include'sunday.php';?>;
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
var n = weekday[d.getDay()];
document.getElementById("subject").innerHTML = n;
}
</script>
<ul id="subject">
<li id="room"></li>
</ul>
sunday -
<ul>
<li id="year">YR: 11</li>
<li id="room">ROOM: DM8</li>
<li id="teacher">TEACHER: K HA</li>
</ul>
Upvotes: 0
Views: 66
Reputation: 76
Your script should
<script>
function myFunction() {
var d = new Date();
var weekday = new Array(7);
weekday[0] = <?php include'sunday.php';?>;
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
var n = weekday[d.getDay()];
document.getElementById("subject").innerHTML = n;
}
</script>
Upvotes: 2