JavaScript and HTML code to print multiplication table of given number - Practical [ SWPD 4311603 ]

Practical Aim:
JavaScript and HTML code to print multiplication table of a given number


JavaScript and HTML code to print multiplication table of given number

First, try at own

Code

multiplication_table_javascript.html file

Javascript to print Multiplication Table

<html>
<head>
<title>JavaScript Multiplication Table</title>
<style>
button {
background-color: Black;
border: none;
color: white;
padding: 10px 10px;
text-align: center;
text-decoration: none;
font-size: 15px;
cursor: pointer;
border-radius: 12px;
}
p{
color: Black;
}
</style>
<script>
function MultiplicationTable() {
var number;
var result = "";

number = Number(document.getElementById("number").value);

for(var i = 1; i<= 10; i++){
result = result + "<p>"+number + "*" + i + "=" + number * i+"</p>";
}

document.getElementById("result").innerHTML = result;
}
</script>
</head>
<body>
Enter the number to get Multiplication Table: <input id="number" /><br><br>
<button onclick="MultiplicationTable()">Print Multiplication table</button>
<div id="result" >
</body>

</html>


Try here

<!DOCTYPE html >
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<h1> Try your code here</h1>
</body>
</html>



Output


Post a Comment

0 Comments