How can I add javascript to MoodleForm in Moodle v1.9.
I tried the following code:
$mform->addElement('static', null,
'<script type="text/javascript">
//<![CDATA[
$(\'input#id_userfile\').change(function() {
var filePath = $(this).val();
if (filePath.indexOf(\'aaa\') > 0)
$(\'select#id_roleassign\').val(\'11\');
else if (filePath.indexOf(\'bbb\') > 0)
$(\'select#id_roleassign\').val(\'22\');
else
$(\'select#id_roleassign\').val(\'\');
});
//]]>
</script>');
But it doesn't seem get javascript into the page source.
Any idea how to add javascript to the MoodleForm code?
Thanks for your help!