I have a radio button, containing an inline onclick
event:
<input type="radio" class="quantitycheckbox" onclick="alterQuantity(this.form)">
I'm trying to unobtrusively add some more functionality on click, and have this code:
function updateCustomFields( box ) {
// save current onclick event before assigning new one
var currEvent = box.onclick;
box.onclick = function() {
currEvent();
// do additional stuff here
}
}
var boxes = $class('quantitycheckbox');
for( var i = 0; i < boxes.length; i++ ) {
updateCustomFields( boxes[i] );
}
However, the value of this.form
that's passed into the alterQuantity
function is undefined, and I get an error. How would I preserver the onclick
event as it is and add my functionality?