0

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>

2
  • What is the error here exactly? d.getday() should be d.getDay() btw. Commented Jan 13, 2019 at 11:11
  • Also there should be a ; after weekday[d.getday()] Commented Jan 13, 2019 at 11:22

1 Answer 1

2

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.