<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK" %>
<%@ include file="/common/taglib.jsp" %>
<%@ include file="/common/common.jsp" %>
<%@ taglib prefix="s" uri="/struts-tags" %><html>
<head>
    <title>机房查询</title>        <!--查询所有机房-->
        function doQuery() {
            window.location.href="<s:url action="list"></s:url>";
        }
        <!--取得查询值-->
        function getSelectValue(property){
            var checkBox = document.getElementsByName("id");
    var valueArray = new Array();
if(isNaN(checkBox.length)) {
if(true == checkBox.checked) {
valueArray.push(checkBox.getAttribute("selectValue"));
}
} else {
for(var i = 0; i < checkBox.length; i++) {
if(true == checkBox[i].checked) {
valueArray.push(checkBox[i].getAttribute("selectValue"));
}
}
}
if(valueArray.length == 0) {
alert("请选择一条记录!");
return null;
} else if(valueArray.length > 1){
alert("只能选择一条记录进行修改!");
return null;
}
return valueArray[0];
    }
    //修改机房
        function modifyjifang(){
            //disableAllBts();
         var ids = getSelectValue();
         if(ids == null){
         return;
         }
         var checkBox = document.getElementsByName("ids");
         var jifangID = getPropetyValue(checkBox,"jifangBianhao");
         alert(checkBox);
         alert(jifangID);
         alert(ids);
         var url="<s:url action="toModify"><s:param name="jid" value="ids" /></s:url>"
         window.location.href=url;

        }
        
         function getPropetyValue(checkbox ,propName){
var propValue;
if(isNaN(checkbox.length)) {
if(true == checkbox.checked) {
propValue = document.getElementsByName(propName)[0].value;
}
} else {
for(var i = 0; i < checkbox.length; i++) {
if(true == checkbox[i].checked) {
propValue = document.getElementsByName(propName)[i].value;
}
}
}
return propValue;
}
//删除机房
        function deletejifang(){
            var id = getSelectValue();
         if(id == null){
         return;
         }
         var checkBox = document.getElementsByName("id");
         var url="<s:url action="delete"><s:param name="jifang.id" value="id" /></s:url>"
         window.location.href=url;
         alert("删除成功");
         window.location.href="jifang_main.jsp";
         }
        
        function addjifang(){
         window.location.href="<s:url action="toAdd"></s:url>";
         }
        
        function queryjifang(){
         window.location.href="<s:url action="detail"><s:param name="jifang.id" value="id" /></s:url>";
         }
    </script>
</head>
<body>
<form action="/examPaperManage.do" method="post">
    
        <table border=0 cellpadding=1 cellspacing=1 class="query_table"
width="100%" align="center">
<tr>
<td align="center">
<div align="left">
    <input type="button" class="btn4" name="btn3" onclick="modifyjifang()" value="修改">
<input type="button" class="btn4" name="btn4" onclick="deletejifang()" value="删除">
<input type="button" class="btn4" name="btn4" onclick="modifyjifang()" value="查询">
<input type="button" class="btn4" name="btn4" onclick="" value="导入">
<input type="button" class="btn4" name="btn4" onclick="" value="导出">
</div>
</td>
    <td align="center">
<div align="right">
<input type="button" class="btn4" name="btn10" onclick="addjifang()" value="增加">
</div>
</td>
</tr>
</table>

        <table border=0 cellpadding=1 cellspacing=1 class="query_table" width="95%" align="center">
            <tr>
                <th colspan="8" nowrap>
                    <div align="left">机房列表</div>
                </th>
            </tr>
            <tr>
                <th width="5%" scope="row">选择
                </th>
                <th width="10%">机房编号
                </th>
                <th width="10%">机房名称
                </th>
                <th width="10%" scope="row">
                 机房类型
                </th>
                <th width="10%" scope="row">
                 机房简称
                </th>
                <th width="10%" scope="row">
                 产权单位
                </th>
                <th width="10%" scope="row">
                 维护单位
                </th>
                <th width="5%" scope="row">详情
                </th>
            </tr>
            
       <s:iterator value="list">
        <tr>
            <td width="5%"><input type="checkbox" name="id" selectValue="<s:property value="id"/>"></td>
            <td width="10%"><s:property  value="jifangBianhao"/></td>
            <td width="10%" ><s:property value="jifangMingcheng"/></td>
            <td width="10%" ><s:property value="jifangleixing"/></td>
            <td width="10%" ><s:property value="jianCheng"/></td>
            <td width="10%" ><s:property value="chanquanDanwei"/></td>
            <td width="10%" ><s:property value="weihuDanwei"/></td>
            <td width="5%">
                <a href='<s:url action="detail"><s:param name="jifang.id" value="id" /></s:url>'>
                    查看
                </a>

            </td>
        </tr>
    </s:iterator>          
        </table>
</form>
</body>
</html>对查询出来的结果进行查看和修改,查看的时候可以把机房传过去。修改的时候就不能了。

解决方案 »

  1.   

      //修改机房
            function modifyjifang(){
                //disableAllBts();
                var ids = getSelectValue();
                if(ids == null){
                    return;
                }
                var checkBox = document.getElementsByName("ids");
    在修改的时候,document.getElementsByName("ids"),这里的ids在<body>标签内部,没有名字为ids的控件,所以js这部分有错误,造成你说的问题存在!
      

  2.   

    楼上说的对  用jQuery吧  用 $("#ID")或者$(".class")  这是潮流 呵呵