This seems relatively straightforward:
$(document).ready(
function(){
$('select').each(
function(){
if ($(this).attr('onChange')) {
var onChangeString = $(this).attr('onChange').replace('change_option','changeoption');
$(this).attr('onChange',onChangeString);
}
}
);
}
);
I used the following (x)html (under a <!DOCTYPE html>
, using Chrome and Firefox on Ubuntu 10.10):
<form action="#" method="post">
<select onChange="change_option('SELECT___100E___7',this.options[this.selectedIndex].value)" name="SELECT___100E___7">
<option value="0">dummy option 1</option>
<option value="1">dummy option 2</option>
<option value="2">dummy option 3</option>
<option value="3">dummy option 4</option>
</select>
<select onChange="change_option('SELECT___123___6',this.options[this.selectedIndex].value)" name="SELECT___123___6">
<option value="0">dummy option 1</option>
<option value="1">dummy option 2</option>
<option value="2">dummy option 3</option>
<option value="3">dummy option 4</option>
</select>
<select onChange="change_option('SELECT___584E___52',this.options[this.selectedIndex].value)" name="SELECT___584E___52">
<option value="0">dummy option 1</option>
<option value="1">dummy option 2</option>
<option value="2">dummy option 3</option>
<option value="3">dummy option 4</option>
</select>
</form>
Demo at JS Fiddle.
Edited to add an afterthought: personally, I'd
strongly recommend removing the
onChange
event from the (x)html, and place all your behavioural logic together, rather than having it strewn around your html pages (because leaving it there leads to situations like
this, having to manipulate a whole bunch of elements instead of rewriting one function in one file.
If you truly can't edit the html you can always use jQuery to remove the onChange
(and onClick
etc.) event handlers, and use a linked js file to take over their function.