Question

1. Create a web page that would display the following message: Play the Game When we click on the text, we should see the fol

0 0
Add a comment Improve this question Transcribed image text
Answer #1
  • Hello.! Dear Student,
  • I have try my best to get your solution. If you have any query then you can ask me in comment i will help you. Thank you :)
  • if possible then rate the answer as well.

Solution:

  • I have made a simple webpage using HTML which contains the text "Play the game".
  • When user click on text then javascript function will call name as factorial().
  • In Factorial()
    • First, Prompt will open for ask the user to a number. If user user enter anything exept number then aleart box will show the user to "Enter number only". else program will continue and print the ouput.

CODE:-

========================================= index.html =============================

<!DOCTYPE HTML>
<html>
<head>
<title>
Play the Game
</title>
</head>   
<body>
<!-- When user click on the below text the factorial() will call by using pre-defined onclick attribute-->
<div id="game" onclick="factorial()">
Play a Game
</div>

<!-- This div is used for the show the output -->
<div id="output">
  
</div>

<!-- Javascript-->
<script type="text/javascript">
  
//Function for calculate the factorial
function factorial()
{
//prompt box open for get the number from user
var number = prompt('Please Insert a Number'); //User input will store on variable number.

//Here,Check the user enter a Number or String
if(isNaN(number))
{
//if user enter anything else except number then alert box will diplay to the use.
alert("Please Enter a Number only");
}
else
{
//if user enter number then find the factorial.

//variable fact initialize with 1.
var fact=1;

//variable data is used to store the output (factoail of each number).
var data="";

//loop will continue till the number which provided by user
for (var i = 1; i <= number; i++)
{
fact *=i;
data += "<html><body><center>";
data += fact;
data += "<hr><br></center></body></html>";
}

//here the output will show on the div tag which we have declared above.
output.innerHTML = "<html><center><b>Below are the factorials of all the numbers from 1 to " + number + "<br><br></b>" + data + "</center></html>";
//by using this line the above div tag with id game will be hide.
document.getElementById("game").style.display = "none";
}
}
</script>
</body>
</html>
  

OUTPUT:-

Simple Webpage

Mar 17 12:00 PM G factorial in javascript fo x 3 JavaScript to Fixed() Me x How can I use goto stat x + - 0 x Activities Goog

Prompt Box open when user click the text:How can I use goto stat x | + - * Activities Google Chrome Mar 17 11:58 AM C Play the game * M JavaScript: Adding Extr x G fa

Factorial of user input:

How can I use goto stat x + - 0 x Activities Google Chrome Mar 17 11:59 AM C Play the Game M JavaScript: Adding Extr x G fact

When user input is anything except number:

How can I use goto stat x | + - Activities Google Chrome Mar 17 12:03 PM C Play the game * M JavaScript: Adding Extr x G fact

Alert prompt:

How can I use goto stat x | + - Activities Google Chrome Mar 17 12:05 PM C Play the game * M JavaScript: Adding Extr x G factThank you :)

Add a comment
Know the answer?
Add Answer to:
1. Create a web page that would display the following message: Play the Game When we...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • HTML / CSS Content Requirements Create a home page with the following elements and settings: Set...

    HTML / CSS Content Requirements Create a home page with the following elements and settings: Set the background, font colors, and “theme” to match those used in lab assignment #1 using an external css file; inline styling should be used only where necessary to override styling from the external css H1 element, centered at the top of the page, with “Thank you for choosing Your Company Name. . . “ text* Div or other container with at least 5 sentences...

  • Create an HTML5 page that contains a form to collect the following data. The text in...

    Create an HTML5 page that contains a form to collect the following data. The text in bold indicates the id value that should be assigned to each html control: Product (drop down list) product – iPad, iPhone 6S, Galaxy 5S, Moto X, and so on Quantity (number) quantity Unit price (number) unit_price Discount (%)(number) discount_rate Date (date)   order_date First Name (text box)   first_name Last Name (text box)   last_name Payment type (drop down list)   payment_type – Visa, Master, Discover, Amex, and...

  • HTML Web Page project: Need help to create a web page exactly as the example below...

    HTML Web Page project: Need help to create a web page exactly as the example below using HTML. I need the source code. Page 1 of CA272 Midterm Welcome to your name's CA272 Midterm Text In this class, I learned how to... 1. create an X)HTML web page, where I can 2. change the size of my font, 3. change the color of my fonts, 4. change my font style, 5. and change the background color of my web page....

  • JAVA We will write a psychic game program in which a player guesses a number randomly...

    JAVA We will write a psychic game program in which a player guesses a number randomly generated by a computer. For this project, we need 3 classes, Player, PsychicGame, and Driver. Description for each class is as following: Project Folder Name: LB05 1. Player class a.Input - nickName : nick name of the player - guessedNumber : a number picked for the player will be assigned randomly by a computer later. b. Process - constructor: asks a user player’s nickName...

  • Create a modification to the Hangman game to provide enhancements for the user experience. Share the...

    Create a modification to the Hangman game to provide enhancements for the user experience. Share the code in text format in this thread. Could someone please assist me coming up with a modification in Python? 4. EXERCISE 4 The following code implements a very simple Hangman game: word = 'underutilise guesses = [] user_input = " while user_input == '0': user_input = input ("Enter a letter, or 0 to give up:') guesses.append(user_input) output = '' for letter in range(1, len...

  • Currently, the game allows players to play as many times as they wish. It does not...

    Currently, the game allows players to play as many times as they wish. It does not provide any feedback on how the players are doing, however. Modify the game so that it keeps track of the number of games played as well as the average number of guesses made per game. To implement this change, add the following list of global variables to the beginning of the script’s Main Script Logic section. Assign each variable an initial value of zero....

  • 1) Create a simple AJAX page that converts US Dollars to British Pounds - (use exchange...

    1) Create a simple AJAX page that converts US Dollars to British Pounds - (use exchange rate as of 10/24 - $1 = .80 British Pounds) 2) Your page should have a text box and a button. When the user presses the button, the text box should be validated in JavaScript to make sure the user has entered a numeric value and has not left the field blank. If the form is valid, an AJAX call (XMLHTTP Request) should be...

  • In this assignment you will combine HTML, PHP, and SQL in order to create a web...

    In this assignment you will combine HTML, PHP, and SQL in order to create a web form that allows a manager to add films to the sakila database. You will also create a method to allow the manager to view a list of all films along with their related information, and a list of actors in the movies. Task 1 Create an initial HTML page titled manager.html with 2 buttons. The first button will be labeled “View Films”, and the...

  • (C++) Please create a tic tac toe game. Must write a Player class to store each...

    (C++) Please create a tic tac toe game. Must write a Player class to store each players’ information (name and score) and to update their information (increase their score if appropriate) and to retrieve their information (name and score).The players must be called by name during the game. The turns alternate starting with player 1 in the first move of round 1. Whoever plays last in a round will play second in the next round (assuming there is one).The rows...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT