How To Create A multiplication Table

Hi Friends i Have create a simple program to Display the Multiplication Table .

In This I have used two For loops .

Step 1: We will get the user input and we are storing that value in to " table " variable as follows.

var table = prompt("How Many Tables you Want");

Step 2 : We are starting our table from to and we will with the User data "table " with the following  for Loop

 for (var i = 2; i <=table ; i++);

Then we are creating the div dynamically and inserting the Generated As Follows..

<!DOCTYPE html>

<head>
    <title></title>
    <style>
      
div {
   
    float: left;
    margin: 10px;
    font-size:large;
    width: 130px;
}
    </style>
</head>
<body>
    <script>
        (function () {
            var table = prompt("How Many Tables you Want");
            for (var i = 2; i <=table ; i++) {
                var myElement = document.createElement('div')
                document.body.appendChild(myElement);
                myElement.setAttribute('id', 'demo' + i);
                var myCalc = '';
                for (var j = 1; j <= 10; j++) {
                    myCalc = myCalc + i +" X "+j+ " = "+ i*j+"<br>";
                    console.log(myCalc)
                   
                    document.getElementById('demo' + i).innerHTML = myCalc;
                }
            }
        })();
    </script>
</body>
</html>
  

Comments

Popular posts from this blog

HTML Attributes ....

How to Study Web Developement Course