HTML - Evento onclick no ejecuta

 
Vista:

Evento onclick no ejecuta

Publicado por Juan Manuel Castañeda (6 intervenciones) el 09/02/2008 00:15:45
¿Por que no ejcuta el evento onclick del botón?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="author" content="">
<script type="text/javascript">
function F(var valor){
if (valor>1)
document.write('<br>')
switch (valor){
case 1:
return 1;
break;
case 2:
return F(--valor);
break;
default:
if (valor<1) {
document.write('Error' & valor & "Deber ser Natural");
} else {
return F(--valor)+F(valor-=2);
}
}
}
</script>

<title>Serie de Fibonacci</title>
</head>

<body>
<form name="form1">
<input type="text" name="valor">
<input type="button" name="Calcular" onclick="document.write(F(form1.valor.value))">
</form>

</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de ScriptShow
Val: 359
Bronce
Ha mantenido su posición en HTML (en relación al último mes)
Gráfica de HTML

RE:Evento onclick no ejecuta

Publicado por ScriptShow (409 intervenciones) el 09/02/2008 18:28:01
Saludos Juan Manuel,

El problema está en el script; prueba así:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="author" content="">
<script type="text/javascript">
function F(valor){
if (valor>1)
document.write('<br>')
switch (valor){
case 1:
return 1;
break;
case 2:
return F(--valor);
break;
default:
if (valor<1) {
document.write('Error' & valor & "Deber ser Natural");
} else {
return F(--valor)+F(valor-=2);
}
}
}
</script>

<title>Serie de Fibonacci</title>
</head>

<body>
<form name="form1">
<input type="text" name="valor">
<input type="button" name="Calcular" value="calcula" onclick="F(form1.valor.value)">
</form>

</body>
</html>

Espero que te funcione.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar