Question: In Chapter 9, you created a magic.html page that simulated the behavior of a Magic 8-Ball. As written, your page completely ignores the user's question

In Chapter 9, you created a magic.html page that simulated the behavior of a Magic 8-Ball. As written, your page completely ignores the user's question while randomly selecting from a list of possible responses. Modify your page so that it is less obvious that the entered questions are irrelevant to the page's execution. In particular, the function in the page should use an if statement to make sure the user entered a question. If not (i.e., the value accessed from the text box is the empty string), then the browser should open an alert box reminding the user to enter a question. However, if the user did enter a question (i.e., the text box is not empty), the page should proceed as before and display a randomly chosen answer. For example,

If (document.getElementById('questionBox').value == '') {

alert('You need to enter a question first!');

}

else {

// existing code for selecting and displaying an answer

}

Step by Step Solution

3.49 Rating (179 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (1 attachment)

Word file Icon

1409-C-S-O-S(1057).docx

120 KBs Word File

Students Have Also Explored These Related Operating System Questions!