我正在尝试制作一个每天更新列表的Web应用程序,但是我正在尝试将新的日期/日期链接到我创建的另一个PHP页面。
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>
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>
星期天-
<ul>
<li id="year">YR: 11</li>
<li id="room">ROOM: DM8</li>
<li id="teacher">TEACHER: K HA</li>
</ul>
答案 0 :(得分:2)
您的脚本应该
<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>