<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    	
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width">
<meta name="mobile-web-app-capable" content="yes">
<link rel="icon" sizes="192x192" href="globo.jpg">	

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Clientes</title>
<script type="text/javascript" src="jquery.js"></script>
</head>
<style>
td{
padding:2px;
color:blue;
font-family:Arial;
}

input[type="text"],input[type="number"], input[type="Date"],select,textArea,input[type="search"]{
color:blue;
box-shadow: 2px 2px 2px black; border:0.5px solid #888888;

}
</style>
<body>
<?php 
include("../php/config.php");

?>

<form action="" enctype="multipart/form-data" method="POST">
<div style="width:65%">
Buscar : <input type="search" value="<?php echo $_POST['txt-buscar']?>" placeholder="Buscar cliente..." name="txt-buscar"> <button name="btn-buscar">Buscar</button> <br><br>
<table width="545" border="0" cellpadding="0" cellspacing="0" style="font-size:12PX; width:100%; border-collapse: collapse; border: 0px solid black; ">
  <tr>
    <th align="left">NOMBRES</th>
    
  </tr>

<?php
if(isset($_POST["btn-buscar"])){
$buscar = $_POST["txt-buscar"];
$a = mysql_query("select DISTINCT(nombre) as nombre from prestamos where  nombre like '%".$buscar."%'");

while($row = mysql_fetch_array($a)){
?>
<tr>
	<td><a href="javascript:void(0)" onClick="seleccionar('<?php echo $row['nombre_cliente']?>')"><?php echo $row["nombre_cliente"]?></a></td>


	
<tr>
<?php }
}
?>
</table>
</form>
</div>
</body>
</html>
<script>
function seleccionar(nombre){
	$.get("datos_clientes.php?nombre="+nombre,function(data,estado){
	var datos = JSON.parse(data);
	
var nombre = opener.document.getElementById('cliente').value=datos[1];
var cedula = opener.document.getElementById('cedula').value=datos[0];
var tlefono = opener.document.getElementById('telefono').value=datos[2];
var direccion = opener.document.getElementById('direccion').value=datos[3];
var ocupacion = opener.document.getElementById('ocupacion').value=datos[4];
//var precio = document.getElementById('precio').value
//var select = opener.document.getElementById('precios');
//select.options[select.options.length] = new Option(precio, precio);
self.close();
});
}


</script>
