Hi,
I have an event switcher that checks if there are no records, only one record or many records on a database table.
When there are many records, I want to show a table listing the records with a button to select one row.
When the user selects a row I want to display the different values on the form. How can I archieve this solution?
I have a custom code inside On found of DB READ with html and php code to show the table, but it does not appear.
Thanks.
Joaquín
I have an event switcher that checks if there are no records, only one record or many records on a database table.
When there are many records, I want to show a table listing the records with a button to select one row.
When the user selects a row I want to display the different values on the form. How can I archieve this solution?
I have a custom code inside On found of DB READ with html and php code to show the table, but it does not appear.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
div.tabla{text-align:center;}
div.tabla table{margin: 0 auto;text-align: left;}
td{text-align:center;background-color: #81c2e8;color:#393b41;}
tr{text-align:center;color:#fff;background-color: #81c2e8;}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("table tbody tr").click(function(){
var seleccion = $(this).text();
var arr = seleccion.split("\n");
alert (arr[1].trim());
alert (arr[2].trim());
alert (arr[3].trim());
alert (arr[4].trim());
});
});
</script>
</head>
<body>
<h3 style="text-align: center">Seleccionar uno de los siguientes demandantes</h3>
<div class="tabla">
<table id="demandantes" width="80%" border ="1">
<thead>
<tr>
<th scope="col"><p>ID</p></th>
<th scope="col"><p>Nombre</p></th>
<th scope="col"><p>Primer Apellido</p></th>
<th scope="col"><p>Segundo Apellido</p></th>
<th scope="col"><p>Seleccionar</p></th>
</tr>
</thead>
<tbody>
<?php
foreach ($form->data['Data'] as $d){
echo "<tr>
<td>' .$d['idDemandante']. '</td>
<td>' .$d["nombre"]. '</td>
<td>' .$d["apellido1"]. '</td>
<td>' .$d["apellido2"]. '</td>
<td><button type="button">' ."Seleccionar".'</button></td>
</tr>";
}
?>
</tbody>
</table>
</html>
Thanks.
Joaquín