87,910
社区成员
发帖
与我相关
我的任务
分享
<input type="checkbox" name="type" value="123" checked id="c1">
<input type="checkbox" name="type" value="456" checked id="c2">
<script type="text/javascript">
<!--
function search(){
var type = document.getElementsByName("type");//这里得到的对象貌似没问题
var search = "type=";
for (var i=0;i<type.length;i++) {
if (type[i].checked == true) {
search += type[i].id;
}
}
alert(search);
//window.open("http://localhost:8080/search.jsp?" + search );
}
search();
//-->
</script>
function search(){
var context = document.getElementById("context").value;
var type = document.getElementsByName("type");//这里得到的对象貌似没问题
var search = "type=";
for (i in type) {
alert(i); //奇怪的是长度也会被输出
if (i.checked == true) { //这里更是undefined,没有checked属性
search += i.id;
}
}
search += "&context=" + context;
alert(search);
//window.open("http://localhost:8080/search.jsp?" + search );
}