This post is a kind of a multi-part question, but essentially i'm loading in an array of objects with my products. What I want to do is to create a list of buttons like this:
<?php foreach($records as $product): ?>
<div><?php echo $product->name; ?></div>
<?php endforeach; ?>
On each button click I want information to change to the corresponding product. My question is, what is the best way of accessing this php array in Javascript? Should I convert it into json?
Secondly, what do I use in prototype to make all of those div tags have click events, and how will I identify the product? Should I retrieve the order number of the button clicked and get the information from the json? So, if the 3rd button in the array is clicked I get the 3rd entry in the json?
I'm trying to learn prototype because I like the effects scriptaculuous offers over jquery.