Create a new .html file called ifPractice.html You\'ll need to create two button
ID: 668948 • Letter: C
Question
Create a new .html file called ifPractice.html You'll need to create two buttons. The first button will prompt the user for a number and then produce an alert box telling the user if the number is negative, zero, or positive. The second button asks the user to enter a month (1 for January, 2 for February, etc) and then gives an alert button with the number of days in that month. If the use enters a month that doesn't exist, create an alert button with an error message.I really need help on that please. Create a new .html file called ifPractice.html You'll need to create two buttons. The first button will prompt the user for a number and then produce an alert box telling the user if the number is negative, zero, or positive. The second button asks the user to enter a month (1 for January, 2 for February, etc) and then gives an alert button with the number of days in that month. If the use enters a month that doesn't exist, create an alert button with an error message.
I really need help on that please. Create a new .html file called ifPractice.html You'll need to create two buttons. The first button will prompt the user for a number and then produce an alert box telling the user if the number is negative, zero, or positive. The second button asks the user to enter a month (1 for January, 2 for February, etc) and then gives an alert button with the number of days in that month. If the use enters a month that doesn't exist, create an alert button with an error message.
I really need help on that please.
Explanation / Answer
save it as ifPractics.html
<!DOCTYPE html>
<html>
<body>
<button>Button1</button>
<script>
function myFunction() {
var number = prompt("Please enter number");
if (number ==0) {
alert('zero');
} else if (number < 0) {
alert('nagative');
} else {
alert('positive');
}
}
function daysInMonth(month,year) {
return new Date(year, month, 0).getDate();
}
function myFunction2() {
var number = prompt("Please enter a day");
var month= prompt("Please enter Month number");
if (number ==0) {
alert('zero');
} else if (number < 0) {
alert('nagative');
} else {
if (month<=0) {
alert('Please enter valid month');
} else if (month>12) {
alert('Please enter valid month');
}else{
prompt('number of days remaining: ',daysInMonth(month,2015) - number);
}
}
}
</script>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.