Monday, 16 September 2024

WRITE A JAVASCRIPT TO PRINT DAY OF THE MONTH FROM THE SYSTEM AND USER ENTERED DATES

 <html>

<head>

<title></title>

</head>

<body>

<h2>Print the day of the month from the system and user entered dates</h2>

Enter Date: <input type="date" name="dt_date" id="dt_date"> <br/>

<input type="submit" value="Click Me" onclick="myFunction()"/>

<script language="JavaScript">

function myFunction() {

var date=new Date(document.getElementById('dt_date').value);

var day=date.getDate();

var dayname=date.getDay();

if(dayname==1) {

document.write("You have selected: "+date+" "+"Monday");

}

else if(dayname==2) {

document.write("You have selected: "+date+" "+"Tuesday");

}

else if(dayname==3) {

document.write("You have selected: "+date+" "+"Wednesday");

}

else if(dayname==4) {

document.write("You have selected: "+date+" "+"Thursday");

}

else if(dayname==5) {

document.write("You have selected: "+date+" "+"Friday");

}

else if(dayname==6) {

document.write("You have selected: "+date+" "+"Saturday");

}

else {

document.write("You have selected: "+date+" "+"Sunday");

}

}

</script>

</body>

</html>

No comments:

Post a Comment