[Javascript] Multiplication Tables

Solved
pigeonus Posted messages 3 Status Member -  
 hachim -
Hello,

I would like to create a multiplication table display, but apparently there's a small issue with my code, which is as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Your Multiplication Tables</title> <script type="text/javascript"> <!-- function table_multiplication() { var nombre; var resultat; for (i=1; i<=10; i++) { resultat=nombre*i; window.document.write(nombre+" x "+i+" = "+resultat); } } --> </script> </head> <body style="background-color:white";> <script type="text/javascript"> <!-- nombre=window.prompt("Enter the number for the table:","Enter an integer here"); table_multiplication(nombre); //--> </script> </body> </html>


Nothing displays after entering the number that will generate the multiplication table.
Thank you for illuminating me on my mistakes, and have a nice day! =]
Configuration: Windows XP Firefox 2.0.0.1

2 answers

  1. pigeonus Posted messages 3 Status Member 17
     
    I finally found the solution

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Your multiplication tables</title> <script type="text/javascript"> <!-- function table_multiplication(number) { var i; for (i=0; i<=10; i++) { result=number*i; document.write(number+" x "+i+"="+number*i+"<br>"); } } --> </script> </head> <body style="background-color:white";> <script type="text/javascript"> <!-- number=window.prompt("Enter the table number:","Enter an integer here"); table_multiplication(number); --> </script> </body> </html>
    10
    1. wallaaa
       
      Here is the simplified code:

      <!--
      number = window.prompt("Enter a number");
      for (i = 1; i <= 10; i++) {
      document.write(number + " x " + i + " = " + number * i + "<br>");
      }

      //-->
      1
    2. tadaaa
       
      <!--
      number=window.prompt("Enter the table number:","Enter an integer here");

      var i;
      for (i=1; i<=10; i++)
      {
      document.write(number+" x "+i+"="+number*i+"<br>");
      }
      -->
      0
    3. Tayuna
       
      Thank you!!!!!! It was helpful to me.
      0
    4. hachim
       
      Thank you because it pushed me to go a little further... thank you infinitely.
      0