Press "Enter" to skip to content

Sample Multiplication Table Example in JavaScript

Last updated on October 5, 2019

Program :

<html>

   <head>

      <script language=”javascript”>

                   function display()

                   {

                   a=parseFloat(document.getElementById(“t1”).value);

                   document.write(“<table border=1>”);

                   for(i=1;i<=10;i++)

                   {

                   document.write(“<tr> <td bgcolor=red>”+a+”</td> <td bgcolor=green>*</td> <td bgcolor=yellow>”+i+”</td>”);

                   document.write(“<td bgcolor=orange>=</td> <td bgcolor=grey> “+(a*i)+”</td> </tr>”);

                   }

                   document.write(“</table>”);

                   }

                  </script>

                </head>

                   <body>

                      <input type=”text” id=”t1″/> </br>

                                  <input type=”button” value=”First Button” onClick=”display()”/> </br>

                   </body>

</html>

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *