PHP function with javascript ( onClick )

Hi everyone

I would like to ask a question, not specifically about Yii, but still in PHP.

So i have a list of products shown by a page. The buttons are created dynamically, because they could change at any time (new products, deleted products).

I would like to call a function when i click on those button. To do this, i have to retrieve the ID of the products shown by the buttons… But i did not suceed, as long as the onclick event does not support PHP functions.

Does anybody knows how to do this? I know i’ll have to use AJAX, but i can’t succeed… I’ve seen a HUGE lot of post about this problem, but there are not a single post that explains completely how to do this…

Thanks in advance and sorry for my poor english :)

Javascript is all client side so yes, you’ll have to use Ajax to hook up with a PHP script. You may want to look in to the CHtml::ajaxLink() method.