Calling a function when sending a form

Hi, i am want to call a javascript function when i submit a form. How to i do this

By following any of the hundreds of tutorials on the internet about this? Is there a Cake-specific question here?

I mean with the html helper
I tried
echo $this->Form->end(__(‘Submit’), array( ‘onClick’ => ‘myfunction()’),);
but it deosn’t execute the function

The end function doesn’t take a second parameter. Try this instead:

echo $this->Form->button(__('Submit'), array( 'onClick' => 'myfunction()'));
echo $this->Form->end();

… a good working principle, if you want to just submit the form
step 1: in form create add an ‘id’ to it
step 2: the element e.g. a select box then refers to this element with the onChange event … or you do it with onClick event or similar …

check also the produced html code … you will see, that it is not really a question of cakephp, moreless, to find the right place, where to add the small javascript part … with this approach you can even submit a form with elements outside the form start and end if I am not wrong