JavaScript - Mostrar el nombre de la persona mayor

 
Vista:
sin imagen de perfil

Mostrar el nombre de la persona mayor

Publicado por Bryan (6 intervenciones) el 11/11/2016 13:42:50
hola necesito un poco de ayuda.. tengo este problema solicitar tres nombres en un formulario con sus respectivas edades y al presionar un botón mostrar en otro text el nombre del mayor.
puedo hacer todo pero cuando preciono el boton no me muestra nada.. si alguien me puede indicar que estoy haciendo mal.. les pongo el codigo..


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<html>
<head>
</head>
<body style="margin:0" onresize=ini() onload="ini()">
<div style="position: relative">
<div id=fondo style="position:absolute; top:0; left:0;"></div>
<div id=general style="position:absolute; top:0; left:0;">
<table align="center" border=10 >
<tr>
<td >
<script languaje="JavaScript">
function calcularmayoredad()
{
 
var primernombre = parseInt (document.form1.D1.options [document.form1.D1.selectedIndex].value);<br/>
var primeraedad = parseInt (document.form1.D1a.options [document.form1.D1a.selectedIndex].value);<br/>
 
var segundonombre = parseInt (document.form1.D2.options [document.form1.D2.selectedIndex].value); <br/>
var segundaedad = parseInt (document.form1.D2a.options [document.form1.D2a.selectedIndex].value); <br/>
 
var tercernombre = parseInt (document.form1.D3.options [document.form1.D3.selectedIndex].value); <br/>
var terceraedad = parseInt (document.form1.D3a.options [document.form1.D3a.selectedIndex].value);
 
document.form1.T1.value=primernombre+segundonombre +tercernombre; <br/>
document.form1.T2.value=primeraedad+segundaedad+te rceraedad;
}
</script>
<form name="form1"><br/><br/>
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td onmouseover="this.style.background='red'" onmouseout="this.style.background='white'">
<p>PRIMER NOMBRE:
<input type="text" name="T1" size="20" >
EDAD:
<input type="text" name="T2" size="1">
</td>
</tr>
</table><br/><br/>
 
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td onmouseover="this.style.background='red'" onmouseout="this.style.background='white'">
 
<p>SEGUNDO NOMBRE:
<input type="text" name="T1" size="17">
EDAD:
<input type="text" name="T2" size="1">
</td>
</tr>
</table><br/><br/>
 
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td onmouseover="this.style.background='red'" onmouseout="this.style.background='white'">
 
<p>TERCER NOMBRE:
<input type="text" name="T1" size="20">
EDAD:
<input type="text" name="T2" size="1">
</td>
</tr>
</table>
<script language="javascript" type="text/javascript">
function change()
{
re="rgb("+Math.round(Math.random()*256)+","+Math.r ound(Math.random()*256)+","+Math.round(Math.random ()*256)+")"
text.style.color=re;
}
setInterval(change,1000);
</script><br/>
 
<p><input type="button" value="Nombre de Mayor Edad" name="B1"
onClick="calcularmayoredadca()"> <input type="text" name="T1+T2" size="25"> </p>
 
 
</td><br/>
 
</table>
</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 xve
Val: 3.162
Oro
Ha mantenido su posición en JavaScript (en relación al último mes)
Gráfica de JavaScript

Mostrar el nombre de la persona mayor

Publicado por xve (2100 intervenciones) el 11/11/2016 20:19:52
Hola Bryan, creo que tenias errores en casi todas las lineas... te adjunto tu código corregido para que lo compares.... recuerda que los navegadores llevan una consola para indicar todos los errores que encuentra.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<html>
<head>
</head>
<body style="margin:0">
<div style="position: relative">
<div id=fondo style="position:absolute; top:0; left:0;"></div>
<div id=general style="position:absolute; top:0; left:0;">
<table align="center" border=10 >
<tr>
<td >
<script languaje="JavaScript">
function calcularmayoredad()
{
 
var primernombre = document.form1.T1.value;
var primeraedad = parseInt(document.form1.T2.value);
 
var segundonombre = document.form1.T3.value;;
var segundaedad = parseInt(document.form1.T4.value);
 
var tercernombre = document.form1.T5.value;;
var terceraedad = parseInt(document.form1.T6.value);
 
if(primeraedad>segundaedad && primeraedad>terceraedad)
	document.form1.result.value=primernombre;
else if(segundaedad>terceraedad)
	document.form1.result.value=segundonombre;
else
	document.form1.result.value=tercernombre;
}
</script>
<form name="form1"><br/><br/>
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td onmouseover="this.style.background='red'" onmouseout="this.style.background='white'">
<p>PRIMER NOMBRE:
<input type="text" name="T1" size="20" >
EDAD:
<input type="text" name="T2" size="1">
</td>
</tr>
</table><br/><br/>
 
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td onmouseover="this.style.background='red'" onmouseout="this.style.background='white'">
 
<p>SEGUNDO NOMBRE:
<input type="text" name="T3" size="17">
EDAD:
<input type="text" name="T4" size="1">
</td>
</tr>
</table><br/><br/>
 
<table border=0 cellpadding=0 cellspacing=0>
<tr>
<td onmouseover="this.style.background='red'" onmouseout="this.style.background='white'">
 
<p>TERCER NOMBRE:
<input type="text" name="T5" size="20">
EDAD:
<input type="text" name="T6" size="1">
</td>
</tr>
</table>
<script language="javascript" type="text/javascript">
function change()
{
re="rgb("+Math.round(Math.random()*256)+","+Math.round(Math.random()*256)+","+Math.round(Math.random ()*256)+")"
//text.style.color=re;
}
setInterval(change,1000);
</script><br/>
 
<p><input type="button" value="Nombre de Mayor Edad" name="B1"
onClick="calcularmayoredad()"> <input type="text" name="result" size="25"> </p>
 
 
</td><br/>
 
</table>
</body>
</html>
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