
Ayuda con el botón buscar y registrar en javascript
Publicado por johan (2 intervenciones) el 24/09/2014 07:29:23
Hola quisiera que me ayuden con el boton registrar y buscar en javascript , pues cada vez que lo cargo solo me envia a la opcopn por defecto
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
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html>
<head>
<title></title>
<META CHARSET='UTF-8'></META>
<script type="text/javascript">
var cod = window.document.formu.txt2.value;
var nom = window.document.formu.txt3.value;
var ape = window.document.formu.txt4.value;
var codigos = [''];
var nombres = [''];
var apellidos = [''];
function registrar(){
if(cod == '' || nom == '' || ape == ''){
alert('no deben haber espacios en blanco');
}else{
codigos = [cod];
nombres = [nom];
apellidos = [ape];
alert('datos ingresados');
}
}
function buscar(){
var codigo=document.formu.txt1.value;
for( var i=0;i<=codigos.length;i++){
if(codigo==codigos[i]){
alert('dato encontrado');
document.formu.area.value = codigo + nombres[i] + apellidos[i] ;
break;
}else{
alert('persona no encontrada');
break;
}
}
}
</script>
</head>
<body>
<center>
<form name='formu'>
<table>
<tr>
<td><label>Cogigo:</label><input type='text' name='txt2'/></td>
</tr>
<tr>
<td><label>Nombre:</label><input type='text' name='txt3'/></td>
</tr>
<tr>
<td><label>Apellidos:</label><input type='text' name='txt4'/></td>
</tr>
<tr>
<td><input type="button" value="Registrar" onClick="registrar()" /></td>
</tr>
<tr>
<td><label>Cogigo</label><input type='text' name='txt1'/></td>
<td></td>
</tr>
</fieldset>
<tr>
<td><textarea name='area' cols='22'></textarea> </td>
<td></td>
</tr>
<tr>
<td><input type='button' value='Buscar' onClick='buscar()'/></td>
</tr>
</table>
</form>
<center>
</body>
</html>
Valora esta pregunta


0