I would make two changes:
<input type="radio" name="myRadios" onclick="handleClick(this);" value="1" />
<input type="radio" name="myRadios" onclick="handleClick(this);" value="2" />
onclick
handler instead of onchange
- you're changing the "checked state" of the radio input, not the value
, so there's not a change event happening.this
as a parameter, that will make it easy to check which value is currently selected.ETA: Along with your handleClick()
function, you can track the original / old value of the radio in a page-scoped variable. That is:
var currentValue = 0;
function handleClick(myRadio) {
alert('Old value: ' + currentValue);
alert('New value: ' + myRadio.value);
currentValue = myRadio.value;
}
var currentValue = 0;_x000D_
function handleClick(myRadio) {_x000D_
alert('Old value: ' + currentValue);_x000D_
alert('New value: ' + myRadio.value);_x000D_
currentValue = myRadio.value;_x000D_
}
_x000D_
<input type="radio" name="myRadios" onclick="handleClick(this);" value="1" />_x000D_
<input type="radio" name="myRadios" onclick="handleClick(this);" value="2" />
_x000D_