I passed id from foreach loop and i would like to use the entire row using that id how?
-- my code is
<?php foreach ($products as $product): ?>
<div class="list_item">
<img src="http://localhost/maanyadev/img/uploads/<?php echo h($product['Product']['img']); ?>" height="100" width="100" id="img">
<div><b>Name:</b><?php echo h($product['Product']['name']); ?><br >
<b>Price:</b><?php echo h($product['Product']['price']); ?>
<br >
<!--<?php echo $this->Html->link(('Add to Cart'), array('controller' => 'products', 'action'=>'addtocart', $product['Product']['id'])); ?>-->
<?php
$pd = $product['Product']['id'];
echo $this->Html->link('Addtocart',$product['Product']['id'],array('onClick'=>'test1('.$pd.');return false;')); ?>
</div></div>
<?php endforeach; ?>
and js code is
<script>
function test1(id)
{
alert(id);
// in this are how to use $product['Product']['id'] and other fields how to use here
}
</script>
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment