How To Use Table Multiplication Using Javascript Example

Oct 21, 2021 . Admin



Hello Friends,

Now let's see example of how to use table multiplication example. We will use table multiplication using javascript. This is a short guide on table multiplication. Let's get started with how to table multiplication in javascript.

Here i will give you many example how to use table multiplication using javascript.

Example :
<html>
    <head>
        <title>How To Use Table Multiplication Using Javascript Example - MyWebtuts.com</title>
        <style type="text/css"> 
            .main-section{
                width: 600px;
                margin: 150px auto;
                padding:20px 10px;
                border-radius: 25px;
                text-align: center;
                box-shadow:0px 0px 7px 8px #d2d2d2;
            }       
            table{
                background-color: #C5C5C5;
                margin: 0 auto;
            } 
            th, td {
                padding: 8px;
            }
        </style>
    </head>
    <body>
        <div class="main-section">
            <h2>How To Use Table Multiplication Using Javascript Example - MyWebtuts.com</h2>

            <script type="text/javascript">
                var rows = prompt("How many rows for your multiplication table?");
                var cols = prompt("How many columns for your multiplication table?");
                if(rows == "" || rows == null)
           		    rows = 10;
                if(cols== "" || cols== null)
           		    cols = 10;
                
                createTable(rows, cols);
                function createTable(rows, cols)
                {
                    var j=1;
                    var output="<div width='500' background->"
                    output = output + "<table border='1' width='500' cellspacing='0'cellpadding='5'>";
                
                    for(i=1;i<=rows;i++)
                    {
                	   output = output + "<tr>";
                        while(j<=cols)
                    {
              		    output = output + "<td>" + i*j + "</td>";
               		    j = j+1;
               		}
               		output = output + "</tr>";
               		j = 1;
                }
                output = output + "</table>";
                output = output + "</div>";
                document.write(output);
            }
            </script>
        </div>
    </body>
</html>
Output :

It will help you...

#Javascript