robkar97
12-17-2008, 05:17 AM
Is there a way to append instructions to existing "onchange" event handlers later in the script?
Let's say I got something like this:
<html>
<body>
<select id="myform" onchange="alert('Hi, ' + this.value)">
<option value="bob">Bob</option>
<option value="mike">Mike</option>
</select>
[...]
<script type="text/javascript">
document.getElementById('myform').onchange += function(){alert('How are things today?')};
//this will NOT work...
</script>
</body>
</html>
Let's say I got something like this:
<html>
<body>
<select id="myform" onchange="alert('Hi, ' + this.value)">
<option value="bob">Bob</option>
<option value="mike">Mike</option>
</select>
[...]
<script type="text/javascript">
document.getElementById('myform').onchange += function(){alert('How are things today?')};
//this will NOT work...
</script>
</body>
</html>