日期:2014-05-18  浏览次数:20722 次

一个关于单选按钮的问题,在线等~~~
两组单选按钮,每组单选按钮的数量至少3个,两组单选按钮的选择项之间存在某种相互影响关系,如在第一组中选择了某项后第二组中的某些项就不能选

假设第一组中间有三个学院   A   B   C,第二组是   a   b   c   d   e   f   g   这么多课程,假设第一组按钮中选择了A   ,则第二组按钮只能在   a   b   c   d四门课程中单选一门   请问大家怎么写程序啊   ??

------解决方案--------------------
<%@ page language= "java " pageEncoding= "GBK "%>

<%@ taglib uri= "http://struts.apache.org/tags-bean " prefix= "bean "%>
<%@ taglib uri= "http://struts.apache.org/tags-html " prefix= "html "%>
<%@ taglib uri= "http://struts.apache.org/tags-logic " prefix= "logic "%>
<%@ taglib uri= "http://struts.apache.org/tags-tiles " prefix= "tiles "%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<%@page import= "java.io.File "%>
<html:html lang= "true ">
<head>
<html:base />

<title> MyJsp.jsp </title>

<meta http-equiv= "pragma " content= "no-cache ">
<meta http-equiv= "cache-control " content= "no-cache ">
<meta http-equiv= "expires " content= "0 ">
<meta http-equiv= "keywords " content= "keyword1,keyword2,keyword3 ">
<meta http-equiv= "description " content= "This is my page ">
<!--
<link rel= "stylesheet " type= "text/css " href= "styles.css ">
-->
<script type= "text/javascript ">
function subm(value)
{
var index= " ";//设置只能选择的下标
if(value== "1 ")
{
index= "1,3,5 ";
}else if(value== "2 ")
{
index= "1,2,3 ";
}else
{
index= "4,5 ";
}
var ff=document.getElementsByName( "r2 ");
for(var i=0;i <ff.length;i++)
{
if(index.indexOf(i) <0)
{
ff[i].disabled= "disabled ";
}else
{
ff[i].disabled= " ";
}
}

}
</script>
</head>

<body> ff
<form action= "myAction.do " name= "a " >
<input type= "hidden " name= "ff ">
<input type= "radio " name= "r1 " value= "r11 " onclick= "subm( '1 '); ">
学院A
<input type= "radio " name= "r1 " value= "r12 " onclick= "subm( '2 '); " >
学院B
<input type= "radio " name= "r1 " value= "r11 " onclick= "subm( '3 '); ">
学院C
<br>
<input type= "radio " name= "r1 " value= "a " >
课程a
<input type= "radio " name= "r2 " value= "b " >
课程b
<input type= "radio " name= "r2 " value= "c ">
课程c
<input type= "radio " name= "r2 " value= "d " >
课程e
<input type= "radio " name= "r2 " value= "f " >
课程f
<input type= "radio " name= "r2 " value= "g " >
课程g
<