How do I create a web page that contains four buttons. Each button, when clicked
ID: 3689215 • Letter: H
Question
How do I create a web page that contains four buttons. Each button, when clicked, should cause an alert dialog to display a different time or date in relation to the current time. create a now button that alerts the current time and date and a yesterday button that alerts the time and date 24 hours ago. The other two buttons should alert the time and date ten years ago and one week from today? It wants me to complete this using notepad by saving in HTML and have script forms! Please help I'm confused!
Explanation / Answer
<html>
<head>different date's using alert</head>
<script type="text/javascript">
function display_alert1()
{
var d=new Date();
alert(d);
}
function display_alert2()
{
var d=new Date();
var y=d.getDate()-1;
d.setDate(y);
alert(d);
}
function display_alert3()
{
var tenyearsago=new Date();
tenyearsago.setTime(tenyearsago.valueOf()-10*365*24*60*60*1000);
alert(tenyearsago.toString());
}
function display_alert4()
{
var fromoneweek=new Date();
fromoneweek.setTime(fromoneweek.valueOf()+7*24*60*60*1000);
alert(fromoneweek.toString());
}
</script>
<body>
<br>
<input type="button" value="todays date"><br>
<input type="button" value="yeterdays date"><br>
<input type="button" value="ten years ago date"><br>
<input type="button" value="date from one week">
</body>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.