Boa tarde pessoal. Preciso desenvolver um programa em JavaScript que receba um número do formulário e exiba na tela o fatorial do número digitado e a sua tabuada tudo junto. Já fiz os dois porem não consigo juntar, alguém poderia me ajudar. Fatorial <html>
<head>
<title>Fatorial</title>
</head>
<body>
<script Language="JavaScript">
function calcula_fatorial() {
var numero = prompt("Digite um numero");
var fatorar = parseInt(numero);
var fatorado = 1;
for (var i = numero;i > 1;--i) {
fatorado = fatorado * i;
}
document.write(fatorado);
return;
}
</script>
<form>
<input type="button" value="Calcular fatorial" onClick="java script:calcula_fatorial();" />
</form>
</body>
</html>
Tabuada feita com o formulário.
<html>
<head>
<title> Portifólio 2 </title>
<script type="text/javascript" language="javascript">
function mudaDiv(id, valor) {
if (!isNaN(valor)) {
html_div = document.getElementById(id);
var texto = '';
var valor, i;
for (i=0; i<=10; i++) {
texto = texto + i + ' x ' + valor + ' = ' + i * valor + '<br>';
}
texto = texto + '<br>Repita a operação, substituindo o número ' + valor + ' por outro';
html_div.innerHTML = texto;
}
else {
alert('Apenas numeros');
}
}
</script>
<style type="text/css">
*, html {
margin: 0;
padding: 0;
}
body {
background-color:;
text-align: center;
}
#tabuada, form {
text-align: center;
font-size: 1.2em;
font-weight:bold;
}
#fatorial e tabuada {
padding: 0px 20px;
border: 1px solid #414141;
}
h1 {
font-size:30px;
}
h1, h1 a, a {
color:#009193;
text-decoration: none;
}
a.clique {
color:#900;
text-decoration: underline;
}
h1 a:hover, h2 a:hover, a:hover {
color:#1BA6B2;
}
h2 {
background-color: #a3c159;
text-align: center;
color: #fff;
}
input { margin-top:10px }
#global_rot {
width:690px;
margin:0 auto;
padding:10px 10px 0 10px;
text-align:left;
background-color: #fff;
}
#header {
height:115px;
padding:0 0 0px 18px;
background-color:#ffffff;
background-image:url(header_bg2.jpg);
margin-bottom:2px;
}
#header h1 {
padding-top:35px;
}
form {
margin: 10px;
}
</style>
</head>
<body>
<form name="form1" action="">
<label for="fatoração e tabuada" id="lb">Digite um número para a fatoração e tabuada (por exemplo: 5):</label>
<br />
<input type="text" name="valor" id="valor" size="10" maxlength="10" value="5" /><br /><br />
<a href="#" onclick="mudaDiv('tabuada',document.form1.valor.value)" class="clique">clique aqui para obter os resultados</a>
<br /><br />
</form>
<div id="tabuada"></div>
</div>
</body>
</html> Caso queiram me mandar algum email leandro.desiderio@foster.com.br Att, Leandro Correa Pinto.