I have a little problem to add an external javascript function in a <select>.
I've got a file form.php in /app/code/local/{my_namespace}/{my_module}/Block/Adminhtml/{my_entity}/edit/tab/form.php
I've got another file in js/{my_module}/verifForm.js
In my form.php, there is one select field where I put a : 'onchange' => 'myfunction()'
And myfunction() appear in verifForm.js At the moment, it's just an alert('hello') in it, just to try.
But it doesn't work, when I change the select, my console says : Uncaught ReferenceError: myfunction is not defined
So there is my question, how can I call this external function with my onchange ?
1 Answer 1
You need to use your module layout xml, local.xml or other layout to add your custom javascript to the page header
eg
<yourpackage_yourmodule_yourcontroller_action translate="label" module="yourpackage_yourmodule">
<reference name="head">
<action method="addJs">
<script>{my_module}/verifForm.js</script>
</action>
</reference>
</yourpackage_yourmodule_yourcontroller_action>