Ver Mensaje Individual
  #4 (permalink)  
Antiguo 14/12/2013, 14:09
Avatar de Lynxcraft
Lynxcraft
 
Fecha de Ingreso: noviembre-2007
Ubicación: yecla murcia
Mensajes: 1.346
Antigüedad: 16 años, 5 meses
Puntos: 51
Respuesta: No me lee un objeto

estas seguro de que te lee bien la informacionde del mysql mira desde el codigo fuente esta inea var lista=<?=json_encode($obj);?>; a ver si lo datos te llegan correctamente

otra cosa por que si quieres buscar por en codigo lo por que no lo utilizas como llave

Código PHP:
<?php 
    
include("/conexiones/programa_satbalma.php");    
    
$sql="SELECT *
          FROM prueba"
;
    
$res=$db->query($sql);
    
$obj = array();
    while(
$resultado=mysqli_fetch_row($res)) {
        
$obj["cod_".$resultado[0]]=array( "nom"=>$resultado[1], "pvp"=>$resultado[2]);
    }
?>
<!DOCTYPE HTML>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Documento sin título</title>
<script language="javascript">
var lista=<?=json_encode($obj);?>;
console.log(lista);
function cod(codigo) {
    var nom = lista["cod_"+codigo.value];
    document.getElementById('nom').innerHTML = ( nom )?nom:'no exsite';
}
</script>
</head>
<body>
<table>
    <tr>
        <th width="100px">
            Codigo
        </th>
        <th width="100px">
            Nombre
        </th>
        <th width="100px">
            PVP
        </th>
    </tr>
    <tr>
        <td><input type="text" name="text" id="text" onkeyup="cod(this)"></td>
        <td id="nom"></td>
        <td id="pvp"></td>
    </tr>
</table>
</body>
</html>
__________________
Sobran las ideas cuando faltan ganas de trabajar en ellas
Lynxcraft