2
My problem is this, I can only display the results in one alert
, how I would put the values inside a table?
<title>-Calcular tabuada</title>
<script type="text/javascript">
<
function calcula_tabuada() {
var form = document.getElementById('form');
var n = form.numero.value;
if (n.match(/^[0-9]+$/)) {
var num = parseInt(n);
var resultado = 0;
tabuada = "";
for (operando = 1; operando < 11; operando++) {
resultado = num * operando;
tabuada = tabuada + num + " * " + operando + " = " + resultado + "\n";
}
alert(tabuada);
} else {
alert("Digite um número inteiro válido.");
}
}
//-->
</script>
</head>
<body>
<form id="form" action="" method="get">
<h3>Cálculo da tabuada utilizando for:</h3>
<p>
<label for="numero">Digite o número: </label>
<input type="text" id="numero" name="numero" value="" />
</p>
<p>
<input type="button" value="Calcular" onclick="return calcula_tabuada();" />
</p>
</form>
</body>
</html>
Then develop the page and when you are with some specific question, you put here for us to help you.
– Maniero
Okay, no problem. Thank you
– Guilherme Lima
@Guilhermelima completing what the bigown said, don’t misunderstand, but Stack Overflow is a website of doubts, not requests. Try something, in case of doubt, post your code, your attempt, then yes, many people will help you :).
– Felipe Oriani
Yes, I apologize it was innocence on my part, I updated my doubt.
– Guilherme Lima
I’m no good at manipulating DOM but I guess now who knows can answer.
– Maniero