日期:2014-05-16  浏览次数:20358 次

如果用select 控制radio的选择?
<select   onchange= "a(this) ">
<option   value= " "   remark= " "> </option>
<option   value= "1 "   remark= "A1 "> A </option>
<option   value= "2 "   remark= "B1 "> B </option>
<option   value= "3 "   remark= "C1 "> C </option>
<option   value= "4 "   remark= "D1 "> D </option>
<option   value= "5 "   remark= "E1 "> E </option>
</select>
<input   type= "radio "   name= "field_7 "   value= "pp "> PP
<input   type= "radio "   name= "field_7 "   value= "cc "> CC  
<input   name=remarkInput   value= " "   readonly>
<input   name=remarkInput2   value= " "   readonly>
<script>
function   a(s)
{
v   =   s.options[s.selectedIndex].value
if(   v   ==   "1 ")
{
  document.getElementById( "remarkInput ").value= "1 "
  document.getElementById( "remarkInput2 ").value= "2 "
}
if(   v   ==   "2 ")
{
  document.getElementById( "remarkInput ").value= "a1 "
  document.getElementById( "remarkInput2 ").value= "a2 "
}
}
</script>

如上代码.当选择A时.radio选中PP,当选B时,radio选中CC.
在js中如何控制?当有多个radio时又如何控制?

------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">

<html>
<head>
<meta http-equiv= "pragma " content= "no-cache ">
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 新建网页 </title>
<style type= "text/css ">


</style>
</head>
<body>

<select onchange= "a(this) ">
<option value= " " remark= " "> </option>
<option value= "1 " remark= "A1 "> A </option>
<option value= "2 " remark= "B1 "> B </option>
<option value= "3 " remark= "C1 "> C </option>
<option value= "4 " remark= "D1 "> D </option>
<option value= "5 " remark= "E1 "> E </option>
</select>
<input type= "radio " name= "field_7 " value= "pp "> PP
<input type= "radio " name= "field_7 " value= "cc "> CC
<input name=remarkInput value= " " readonly>
<input name=remarkInput2 value= " " readonly>
<script>
function a(s)
{
v = s.options[s.selectedIndex].value
var field_7 = document.getElementsByName( "field_7 ")
if( v == "1 ")
{
document.getElementById( "remarkInput ").value= "1 "
document.getElementById( "remarkInput2 ").value= "2 "
field_7[0].checked=true;
}
if( v == "2 ")
{
document.getElementById( "remarkInput ").value= "a1 "
document.getElementById( "re