Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
19 views3 pages

Alert

Uploaded by

Pokemon Cartoon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

Alert

Uploaded by

Pokemon Cartoon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

<!

DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lab Work </title>
</head>

<body>
<table>

<tr>
<td> <input type="text" id="sqcb" name="x" placeholder="Enter
a number"></td>
</tr>
<tr>
<td><button onclick="func()">Submit</button></td>
</tr>
<tr>
<td><input type="text" id="fact" name="y" placeholder="Enter a
number"></td>
</tr>
<tr>
<td><button onclick="func1()">Submit</button></td>
</tr>

</table>
<div id="a"></div>
<div id="b"></div>
<div id="c"></div>
</body>

<script>
function func() {
var x, square, cube;
x = parseInt(document.getElementById("sqcb").value);
square = x * x;
cube = x * x * x;

document.getElementById("a").innerHTML = "Square of is: " + square;


document.getElementById("b").innerHTML = "Cube of is: " + cube;

function func1(){
var y,factorial;
y=parseInt(document.getElementById("fact").value);
var factorial=1;
if(y==0||y==1){
document.getElementById("c").innerHTML="factorial is:"+factorial;
}
else if(y>1){
for(let i=2;i<=y;i++){
factorial=factorial*i;
}
document.getElementById("c").innerHTML="factorial is:"+factorial;
}
}

</script>

</html>

Answer:- alert messages and dialogue box:-

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alert messages</title>
</head>

<body>
<script>
alert("Good Morning");
var name = prompt("What is your name?");
alert("Hello" + name + "!");
var ans = confirm("do you want to stay with us");
if (answer) {
alert("Thank u for staying with us");
} else {
alert("thank u for visiting us. Please, visit again. Good Bye");
}
</script>

</body>
</html>

You might also like