
funcion para llenar input con registro de tabla al presionar un boton "seleccionar"
Publicado por Jessica (6 intervenciones) el 27/10/2017 20:27:09
Hola, tengo el siguiente código que me trae al input " numConEq" el numero de control de la fila que selecciono, que es el primero en este caso, pero cuando doy click en el boton "seleccionar" de cualquier otra fila ya no hace nada o me mantiene el mismo numero de control de la primera fila. No se que este mal con mi función o si alguien puede ayudarme a corregirla si tengo algo mal. Lo que realmente quiero hacer es pasar toda la fila que seleccione con el boton "seleccionar" a los input que corresponden en el formulari: ej. numero de control con el registro numConEq, numero de inventario con el registro numInvEq y asi.
// Les dejo mi función java Script.
// Les dejo mi función java Script.
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
function volcar_valores(teq) {
tr = document.getElementById(teq);
td = tr.getElementsByTagName('td');
idDiv = document.getElementById('numInvEq');
inputDiv = idDiv.getElementsByTagName('input');
for (i = 0; i < td.length; i++)
{
inputDiv[i].value = td[i].innerHTML;
}
}
// Input NumControl
<div class="form-group" >
<label for="num_control_eq" class="col-sm-2 control-label">No. Control:</label>
<div class="col-sm-10" id="numConEq">
<input type="text" class="form-control" id="num_control_eq" name="num_control_eq"
placeholder="Ej. ALE0016">
</div>
</div>
// TABLA
<table id="teq">
<thead>
<tr>
<th id = "nce">N° Control</th>
<th id = "nie">N° Inventario</th>
<th id = "te">Tipo Equipo</th>
<th id = "me">Marca</th>
<th id = "nse">N° Serie</th>
<th id = "ae">Área</th>
<th id = "acce">Acción</th>
</tr>
</thead>
<?php while ($row1 = sqlsrv_fetch_array($result1)) {
?>
<tbody class="contenidobusqueda">
<tr>
<td id="first-child"><?php echo $row1['numControl']; ?></td>
<td id="second-child"><?php echo $row1['numContraloria']; ?></td>
<td id="third-child"><?php echo $row1['tipoEquipo']; ?></td>
<td id="fourth-child"><?php echo $row1['marca']; ?></td>
<td id="fifth-child"><?php echo $row1['serie']; ?></td>
<td id="sixth-child"><?php echo $row1['NombreArea']; ?></td>
<td><button type="button" class="btn btn-default"
onclick="volcar_valores('teq')">Seleccionar</button></td>
</tr>
</tbody>
<?php } ?>
</table>
Valora esta pregunta


0