Write JavaScript to perform the following tasks: 1. Using the alert() method, wr
ID: 3647145 • Letter: W
Question
Write JavaScript to perform the following tasks:1. Using the alert() method, write the message "Welcome to [ Your Name's] website" so that the message shows up everytime the page is loaded.
2. Using the prompt() method, ask the user to enter the artist's name, the number of DVDs, the number of CDs and the number of audio cassette's the user wishes to purchase. Save the answers in seperate variables. Also use a seperate prompt for each value.
3. Once the user has entered all information, use the confirm method to display the values entered. Use a single confirm for this purpose. Assume that the user is going to click OK. You do not need to handle the case of the user clicking on Cancel for this assignment. <>Calculate the total value of purchases. To calculate value use the formula: Final Value = (no. of DVDs ordered * 10) + (no. of CDs ordered * 7) + (no. of audio cassettes ordered * 5)
4. Display the following output using the document.write method to display on the webpage the final amount. The output should look something like this:
YOUR ORDER
Artist name:
No. of DVDs:
No. Of CDs:
No. of Audio Cassettes:
Total value of your order:
Explanation / Answer
the entire document prepared is here,
/* <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function f1(){
alert("Welcome");
};
var a=prompt("artist name:");
var b=prompt("enter no.of DVD's");
var c=prompt("enter no.of CDs");
var d=prompt("enter no.of audiocassettes");
var t;
if(confirm("do u wish to display the values?"))
{
t=(b*10)+(c*7)+(d*5);
}
document.writeln("YOUR ORDER ");
document.writeln("Artist name:"+a);
document.writeln("No. of DVDs:"+b);
document.writeln("No. Of CDs:"+c);
document.writeln("No. of Audio Cassettes:"+d);
document.writeln("Total value of your order:"+t);
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html> */
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.