java 显示星期,在java脚本中显示星期几

I need to - Create a HTML form with a text entry field and a button.. When a number is entered in the text entry field and the button clicked a Javascript function called DayOfTheWeek() is invoked. This function uses a switch statement to determine the day of the week corresponding to the number entered, i.e if the number entered is 1 the message “It’s Monday” is displayed, if the number entered is 2 the message “It’s Tuesday” is displayed and so on. If a number which is not between 1-7 is entered then the message “Not a valid day of the week” is displayed.

my html

my java script

function days(dayOfTheWeek)

{

switch (dayOfTheWeek) {

case “1”:

alert(“It\’s Monday”);

break;

case “2”:

alert(“It\’s Tuesday”);

break;

case “3”:

alert(“It\’s Wednesday”);

break;

case “4”:

alert(“It\’s Thursday”);

break;

case “5”:

alert(“It\’s Friday”);

break;

case “6”:

alert(“It\’s Saturday”);

break;

case “7”:

alert(“It\’s Sunday”);

break;

default:

alert(“Not a valid day”);

break;

}

}

PLEASE HELP I keep getting an error with firebug saying days is not defind

解决方案

function days(dayOfTheWeek) {

var weekday=new Array(7);

weekday[0]="Sunday";

weekday[1]="Monday";

weekday[2]="Tuesday";

weekday[3]="Wednesday";

weekday[4]="Thursday";

weekday[5]="Friday";

weekday[6]="Saturday";

var n = weekday[dayOfTheWeek];

return n;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值