[Javascript] Multiplication Tables

Solved
pigeonus Posted messages 3 Status Membre -  
 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 réponses

pigeonus Posted messages 3 Status Membre 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
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
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
Tayuna
 
Thank you!!!!!! It was helpful to me.
0
hachim
 
Thank you because it pushed me to go a little further... thank you infinitely.
0