Hi Folk
I want to add an "onClick" function to the radio boxes, but I am
having trouble. Can you help me
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>leetMachines</title>
<style>
body {width: 600px; margin-left: auto; margin-right: auto;}
label {display: block;}
h2 {color: green;}
p.moreinfo {float: right;}
d.options {clear: right;}
h2, p, div {margin: 0px; padding: 0px;}
</style>
<script type="text/javascript">
function starter(elname) {
obj = document.getElementById(elname);
addclicks(obj);
}
function addclicks() {//gets all variables from a form
for (i=0; i < obj.childNodes.length; i++) {
var newobj = obj.childNodes[i];
tgname = newobj.tagName
if(tgname) {
if (tgname == "INPUT" || tgname == "input") {
newObj.onClick = gonow;
}
}
addclicks(newobj);
}
}
function gonow() {
alert("click");
}
</script>
</head>
<body onload="starter('former');">
<form method="post" action="" name="former" id="former" onclick="">
<h2>Choose below</h2>
<div class="options" id="item1-options">
<label for="item1"><input type="radio" name="item1" value="0"
id="item1-option0" />option 1</label>
<label for="item1"><input type="radio" name="item1" value="1"
id="item1-option1" />option 2</label>
<label for="item1"><input type="radio" name="item1" value="2"
id="item1-option2" />option 3</label>
</div>
</form>
</body>
</html>