This is my question, because in this example I'm doing an array with javacript, where I actually do that array in a sql query (PDO) and send it in a onclick='verProveedores(<?php echo json_encode($datos);?>)';
Until there is no problem because it sends it correctly, the question is that I do not know how to show several values of that array in an alert, I have only been able to print only independent values, in this case in a Alertify.alert();
That's why the purpose of this post, I appreciate your help.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/[email protected]/build/alertify.min.js"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/[email protected]/build/css/alertify.min.css" />
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/[email protected]/build/css/themes/default.min.css" />
<html>
<head>
<tittle>Mostrar lista en js</tittle>
</head>
<body><h2>
<div id="labelalmacen" onclick='verProveedores();'> Haga Click para mostrar lista.
</div></h2>
<script>
var proveedores=[{"nombre_proveedor":"PROVEEDOR1","0":"PROVEEDOR1"},{"nombre_proveedor":"PROVEEDOR2","0":"PROVEEDOR2"},{"nombre_proveedor":"PROVEEDOR3","0":"PROVEEDOR3"},{"nombre_proveedor":"PROVEEDOR4","0":"PROVEEDOR4"}];
function verProveedores() {
alertify.alert("Lista Proveedores:", proveedores[1].nombre_proveedor);
}
</script>
</body>
</html>