<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<input type="checkbox" id="c1" value="c1" />c1
<input type="checkbox" id="c2" value="c2" />c2
<input type="checkbox" id="c3" value="c3" />c3
<input type="checkbox" id="c4" value="c4" />c4
<input type="checkbox" id="c5" value="c5" />c5
<input type="checkbox" id="c6" value="c6" />c6
<input type="checkbox" id="c7" value="c7" />c7
<input type="checkbox" id="c8" value="c8" />c8
<input type="checkbox" id="c9" value="c9" />c9
<input type="checkbox" id="c10" value="c10" />c10
<input type="button" value="test" onclick="xlh()" /><script type="text/javascript">
var flag = 0;
var arr = new Array();
var xlh = function(){
for(var i=0;i<9;i++){
if(eval("c"+(i+1)).checked){
flag += 1;
arr.push("c"+(i+1));
}
}
if(flag !=0 && flag <4){
alert(arr.join("."));
}else{
alert("您选择超过了3条 或者 您根本就没选择");
}
}
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<input type="checkbox" id="c1" value="c1" />c1
<input type="checkbox" id="c2" value="c2" />c2
<input type="checkbox" id="c3" value="c3" />c3
<input type="checkbox" id="c4" value="c4" />c4
<input type="checkbox" id="c5" value="c5" />c5
<input type="checkbox" id="c6" value="c6" />c6
<input type="checkbox" id="c7" value="c7" />c7
<input type="checkbox" id="c8" value="c8" />c8
<input type="checkbox" id="c9" value="c9" />c9
<input type="checkbox" id="c10" value="c10" />c10
<input type="button" value="test" onclick="xlh()" /><script type="text/javascript">
var flag = 0;
var arr = new Array();
var xlh = function(){
for(var i=0;i<9;i++){
if(eval("c"+(i+1)).checked){
flag += 1;
arr.push("c"+(i+1));
}
}
if(flag !=0 && flag <4){
alert(arr.join("."));
}else{
alert("您选择超过了3条 或者 您根本就没选择");
}
}
</script>
</body>
</html>
var xlh = function(){
var flag = 0;
var arr = new Array();
for(var i=0;i<9;i++){
if(eval("c"+(i+1)).checked){
flag += 1;
arr.push("c"+(i+1));
}
}
if(flag !=0 && flag <4){
alert(arr.join("."));
}else{
alert("您选择超过了3条 或者 您根本就没选择");
}
}
</script>
所以又改了一次,下面的可以在不同的流行浏览器得到支持吧:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
var xlh = function(){
var flag = 0;
var arr = new Array();
for(var i=0;i<10;i++){
if(document.getElementById("c"+(i+1)).checked){
flag += 1;
arr.push("c"+(i+1));
}
}
if(flag !=0 && flag <4){
alert(arr.join("."));
}else{
alert("您选择超过了3条 或者 您根本就没选择");
}
}
</script>
</head><body>
<input type="checkbox" id="c1" value="c1" />c1
<input type="checkbox" id="c2" value="c2" />c2
<input type="checkbox" id="c3" value="c3" />c3
<input type="checkbox" id="c4" value="c4" />c4
<input type="checkbox" id="c5" value="c5" />c5
<input type="checkbox" id="c6" value="c6" />c6
<input type="checkbox" id="c7" value="c7" />c7
<input type="checkbox" id="c8" value="c8" />c8
<input type="checkbox" id="c9" value="c9" />c9
<input type="checkbox" id="c10" value="c10" />c10
<input type="button" value="test" onclick="xlh()" /></body>
</html>
改成charset=GBK就显示正常了