I'm using laravel for a project, I present the following problem, in the controller I have an array called scaling value that is filled, then that array was sent to view using return and compact, in the view I need to pass that array to a script and traverse it within javascript, the php array passed to the script as follows in the blade view:
<script>
var cont= "<?php echo $count; ?>";
for (var index1 = 0; index1 < cont; index1++) {
precioesca[index1]="<?php echo $escalafonvalor[".index1."] ?>";
alert(precioesca[index1]);
}
</script>
the array arrives in this way:
array:3 [▼
0 => 13282000
1 => 4688000
2 => 2344000
]
The array passes correctly to the script, because if I give it index 0 it shows its value and stores it in the variable js. My problem is, when trying to traverse the array with the variable index1 of the javascript for, since it tells me that the variable index1 is undefined:
What can be wrong here? or how should it be done?