SoFunction
Updated on 2025-02-28

js dynamically set the value of div below example


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>js dynamically sets the value of div.html</title>

</head>

<body>
<form method="post" name="form1">
<label><input type="radio" name="radio" value="1-10 years old" onclick="ok();">1-10 years old</label>
<label><input type="radio" name="radio" value="11 years old" onclick="ok();">11 years old</label>
<label><input type="radio" name="radio" value="12-120 years old" onclick="ok();">12-120 years old</label>
<input type="button" onclick="ok()" value="test selection value">
</form>

<div ></div>
<script language="javascript" type="text/javascript">
<!--
function ok()
{
var temp=("radio");
for (i=0;i<;i++){
//Travel over Radio
if(temp[i].checked)
{
//alert("You selected"+temp[i].value);
//Get the value of Radio
('test').innerHTML = temp[i].value;
}
}
}
-->
</script>

</body>
</html>