<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content=""><script type="text/javascript">
<!--
/*
*功能:居住在海南选"是",城市选"海口",选否,则不选城市
*/
function check(){
var province = document.getElementsByName("province");//省份
var a;
var provinceValue;
for(a=0; a<province.length; a++){//遍历单选框
if(province[a].checked){
provinceValue = province[a].value;
}
}
var city = document.getElementsByName("city");//城市
var i;
if(provinceValue==1){
for(i=0; i<city.length; i++){//遍历单选框
if(city[i].value==1){
city[i].checked = "checked";
}
}
}else{
for(i=0; i<city.length; i++){//遍历单选框
if(city[i].checked){
city[i].checked = "";
}
}
}
}
/*
*功能:居住在海南选"是",城市选择除海口之外的城市都会弹出提示并选择海口
*/
function doCheckedCity(){
var province = document.getElementsByName("province");//省份
var a;
var provinceValue;
for(a=0; a<province.length; a++){//遍历单选框
if(province[a].checked){
provinceValue = province[a].value;
}
}
var city = document.getElementsByName("city");//城市
var i;
if(provinceValue==1){
for(i=0; i<city.length; i++){//遍历单选框
if(city[i].checked && city[i].value!=1){
city[i].checked = "";
alert("居住在海南选择'是',则城市只能选择海口");
}
}
for(i=0; i<city.length; i++){//遍历单选框
if(city[i].value==1){
city[i].checked = "checked";
}
}
}else{
for(i=0; i<city.length; i++){//遍历单选框
if(city[i].checked && city[i].value==1){
city[i].checked = "";
alert("居住在海南选择'否',则城市不能选择海口");
}
}
}
}
//-->
</script>
</head>
<body>
居住在海南:
<input type="radio" id="province" name="province" value="1" οnclick="check()" checked="checked" >是
<input type="radio" id="province" name="province" value="0" οnclick="check()" >否
<br>
城市:
<input type="radio" id="city" name="city" value="1" οnclick="doCheckedCity()" checked="checked" >海口
<input type="radio" id="city" name="city" value="2" οnclick="doCheckedCity()" >上海
<input type="radio" id="city" name="city" value="3" οnclick="doCheckedCity()" >北京
<input type="radio" id="city" name="city" value="4" οnclick="doCheckedCity()" >武汉
</body>
</html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content=""><script type="text/javascript">
<!--
/*
*功能:居住在海南选"是",城市选"海口",选否,则不选城市
*/
function check(){
var province = document.getElementsByName("province");//省份
var a;
var provinceValue;
for(a=0; a<province.length; a++){//遍历单选框
if(province[a].checked){
provinceValue = province[a].value;
}
}
var city = document.getElementsByName("city");//城市
var i;
if(provinceValue==1){
for(i=0; i<city.length; i++){//遍历单选框
if(city[i].value==1){
city[i].checked = "checked";
}
}
}else{
for(i=0; i<city.length; i++){//遍历单选框
if(city[i].checked){
city[i].checked = "";
}
}
}
}
/*
*功能:居住在海南选"是",城市选择除海口之外的城市都会弹出提示并选择海口
*/
function doCheckedCity(){
var province = document.getElementsByName("province");//省份
var a;
var provinceValue;
for(a=0; a<province.length; a++){//遍历单选框
if(province[a].checked){
provinceValue = province[a].value;
}
}
var city = document.getElementsByName("city");//城市
var i;
if(provinceValue==1){
for(i=0; i<city.length; i++){//遍历单选框
if(city[i].checked && city[i].value!=1){
city[i].checked = "";
alert("居住在海南选择'是',则城市只能选择海口");
}
}
for(i=0; i<city.length; i++){//遍历单选框
if(city[i].value==1){
city[i].checked = "checked";
}
}
}else{
for(i=0; i<city.length; i++){//遍历单选框
if(city[i].checked && city[i].value==1){
city[i].checked = "";
alert("居住在海南选择'否',则城市不能选择海口");
}
}
}
}
//-->
</script>
</head>
<body>
居住在海南:
<input type="radio" id="province" name="province" value="1" οnclick="check()" checked="checked" >是
<input type="radio" id="province" name="province" value="0" οnclick="check()" >否
<br>
城市:
<input type="radio" id="city" name="city" value="1" οnclick="doCheckedCity()" checked="checked" >海口
<input type="radio" id="city" name="city" value="2" οnclick="doCheckedCity()" >上海
<input type="radio" id="city" name="city" value="3" οnclick="doCheckedCity()" >北京
<input type="radio" id="city" name="city" value="4" οnclick="doCheckedCity()" >武汉
</body>
</html>