How can i call a javascript function when clicking a select box?

Hi, im trying to call a javascript function i need to use when user clicks on a select box(its to use a dinamic input) but im not still able to make it posible cause i dont now how to call a javascript function from a form control, i hope anybody can help me.(im new cakephp and i dont have enough knowledge about the framework)

This post dealt with the topic and @zuluru gives a little bit of code at the end that shows how to do it

https://discourse.cakephp.org/t/calling-a-function-when-sending-a-form/

Hi, just a “real world example” … see form->create( … id …) and the onChange option in the form control for s_user … the setTemplates you can ignore and not important

        <?php
            echo $this->Form->create(null,['type' => 'get', 'valueSources' => 'query', 'id' => 'formUserSelect']);
            $this->Form->setTemplates(['inputContainer' => '<div>{{content}}</div>']);
            echo $this->Form->control('s_user', [  'label' => __('Customer select'), 
                                                'options' => $users, 
                                                'empty'=>__('All customers'),
                                                'onChange' => 'document.getElementById("formUserSelect").submit();'
                                                ]);
            $this->Form->end()
        ?>