This is my doubt, because in this example I am making an array with javacript, where I actually do that array in a sql(PDO) query and send it in a onclick='verProveedores(<?php echo json_encode($datos);?>)';
So far there is no problem because it sends it correctly, the question is that I don't 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();
For that reason 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>
[SOLVED] I continued investigating until I gave how to print several values of the same field in an alert using Alertifyjs, everything was in the
data='';
who is variable and it will be used as a counter to show the message several times and stack it as an array when using the itself in the loopfor(){}
just inside the loop itself is used at the enddata=('mensaje'+ array)+data;
<---here's the trick, add it to itself and then place it in an alert.