Help with CButtonColumn click

Hi again,

This is probably a stupid question, but anyway:

I have these buttons inside a CButtonColumn like this:


array

(

    'class'=>'CButtonColumn',

    'template'=>'{present}{absent}',

    'buttons'=>array

    (

        'present' => array

        (

            'label'=>'Set Present',

             'click'=>'js:function (e) { e.setAanwezig	(); alert("aanwezig!"); }',


            

        ),

        'absent' => array

        (

            'label'=>'Set Absent',

             'click'=>'function(){setAfwezig();}',


        ),

    ),

)

And I have 2 functions defined in the page model like this:


public function setAanwezig() {

		$link = mysql_connect('localhost', 'root', '');

		mysql_select_db('pssd');

		

		$sql = "UPDATE `tblaanwezigheid` SET `aanwezig` = '1' WHERE `id-aanwezigheden` = '3'";

		$query = mysql_query($sql);

		

	}

	

	public function setAfwezig() {

		$link = mysql_connect('localhost', 'root', '');

		mysql_select_db('pssd');

		

		$sql = "UPDATE `tblaanwezigheid` SET `aanwezig` = '0' WHERE `id-aanwezigheden` = '3'";

		$query = mysql_query($sql);

		

	}

But when I click either of these buttons, nothing happens…

So my question is, how do I call the function when I click the buttons?

Thanks in advance.

You need to understand one important thing… and that is the difference between PHP and javascript

You are trying to call a PHP function from javascript… that is not working !

To get a result from a PHP function in a javascript you need to use ajax… call a page URL that will execute the function you need and output the data you need… then with javascript you can manipulate that data and insert it on the current page…

But this are all advanced methods…

You cannot call a php method from a js function.

You should do an ajax request if you need information from the server. Transform this function into action and call with ajax

Can I do the MySQL update directly when I click the button? Without calling a function or an action?

You would like to do a mysql update from javascript? … that does not work, too…