//html网页代码
<tr>
<td>
<input type="checkbox" name="vehicle_qx" id="vehicle_qx" value="0" onclick="vehicle_qx(0)"/><font>全部</font>
<input type="checkbox" name="vehicle" value="1" onclick="vehicle_qx(1)"/><font>商务类</font>
<input type="checkbox" name="vehicle" value="2" onclick="vehicle_qx(2)"/><font>豪华类</font>
<input type="checkbox" name="vehicle" value="3" onclick="vehicle_qx(3)"/><font>舒适类</font>
<input type="checkbox" name="vehicle" value="4" onclick="vehicle_qx(4)"/><font>普通类</font>
</td>
</tr>
javascript 代码:
<script type="text/javascript">
function vehicle_qx(value){
if(value==0){
if($("[name=‘vehicle_qx‘]").is(‘:checked‘)){
$("[name=‘vehicle‘]").attr("checked",true);
}else{
$("[name=‘vehicle‘]").attr("checked",false);
}
}else{
var n="0";
var m=$("[name=‘vehicle‘]");
for ( var i = 0; i < m.length; i++) {
if(m[i].checked){
n=parseInt(n)+1;
}else{
}
}
if(n=="4"){
$("[name=‘vehicle_qx‘]").attr("checked",true);
}else{
$("[name=‘vehicle_qx‘]").attr("checked",false);
}
}
}
</script>