how to call a java script function onclick of a button

hi i have a test.js in C:\xampp\htdocs\test\protected\views\topic\js…i have successfully registered…

Now i want to call a function setTop() (i.e function in the test.js file)on a click of a button.

i have written this code(in view) and its not working…

i am a newbie…not able to figure out the error

echo CHtml::button("(+)",array('title'=>"Topic",'onclick'=>setTop()));

plz help.


thanks samdark…

but not working…

Check your code, because it should work.

echo CHtml::button("(+)",array('title'=>"Topic",'onclick'=>'js:setTop();'));

PS: Please paste here the resultant HTML if it doesnt work.

thanks Antonio. my code problem…fixed it