I have a problem creating buttons with a for
and putting within onclick
the name of a function with a parameter, but this parameter is a string, which I get from array
and at the end of the cycle all the buttons have the name of the last element of the array and not of each position of the array.
<?php
for ($i = 0; $i < count($formatos); $i++)
{
?> <script type="text/javascript"> var per=<?php
echo json_encode($formatos[$i]['idPeriodo']);
?>; </script> <button onclick="enviar(per)">Guardar</button> <?php
}
?>