<html>
<head>
<title>Radio Button onClick Handler</title>
<script type="text/javascript">
var myFlag = false
function initValue() {
myFlag = document.forms[0].sizes[0].checked;
}
function sh(form) {
for (var i = 0; i < form.sizes.length; i++) {
if (form.sizes[i].checked) {
break;
}
}
alert(form.sizes[i].value);
}
function setmyFlag(setting) {
myFlag = setting;
}
function exitMsg() {
if (myFlag) {
alert("exit message.");
}
}
</script>
</head>
<body onload="initValue()" onunload="exitMsg()">
<form>
<input type="radio" name="sizes" value="1" checked="checked" onclick="setmyFlag(true)" />1
<input type="radio" name="sizes" value="2" onclick="setmyFlag(false)" />2
<input type="radio" name="sizes" value="7" onclick="setmyFlag(false)" />7
<input type="radio" name="sizes" value="5" onclick="setmyFlag(false)" />5
<input type="button" name="Viewer" value="View" onclick="sh(this.form)" /></p>
</form>
</body>
</html>
|