I just found the "Drupal" way of doing this.
Step 1, set a variable to contain dropdown by using drupal_add_js:
drupal_add_js(array('mymodule' => array('varname' => 'catalogsearch')), 'setting');
Step 2, add the 'onchange' line as
'onchange' => 'change_action(Drupal.settings.mymodule.varname, this.selectedIndex)'
By doing this, the variable is passed without the need of '
to be passed through the theme system. The theme system always calls check_plain
on attribute values, therefore '
or \'
is always converted to '
.