Sunday, 15 September 2024

WRITE A JAVASCRIPT TO PRINT WEEKDAY USING SWITCH STATEMENT


CODE :-

<html>

<head>

<title>Weekday</title>

<script type="text/javascript">

function check()

{

var no=parseInt(prompt("Enter Number="));

switch(no)

{

case 1:

document.write("Monday");

break;

case 2:

document.write("Tuesday");

break;

case 3:

document.write("Wednesday");

break;

case 4:

document.write("Thursday");

break;

case 5:

document.write("Friday");

break;

case 6:

document.write("Saturday");

break;

case 7:

document.write("Sunday");

break;

default:

document.write("Invalid Choice");

}

}

</script>

</head>

<body>

<form name="form1" method="post" onsubmit="return check()">

<input type="submit" name="submit" value="Submit">

</form>

</body>

</html>


No comments:

Post a Comment