jquery的:
$('#disser').live('click',function(){
var code=$('#districtCode').val().trim();
$("tr[id=disTR]").hide();
$("td[id^="+code+"]").parents("#disTR").show();
});
html: <table cellspacing="0" border="0" cellpadding="0" width="100%">
<tr class="bottom_bg"><td>&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;</td></tr>
<tr>
<td class="left_menu_bg02">
<div style="width: 340px; height: 150px; margin-top: 0px; overflow: auto;"
class="left_menu_bg2" id="menuList">
<table width="100%"   class="listStyle"  id="distable">
    <tr><th width="40px">&nbsp;&nbsp;</td>
<th width="70px">地区代码</td>
<th>地区名称</td></tr>
<c:forEach items="${dis}" var="dis">
<tr id="disTR"><td><input type="checkbox"/></td>
<td id="${dis.districtCode}">${dis.districtCode}</td>
<td id="${dis.districtFullName}">${dis.districtFullName}</td></tr>
</c:forEach>
</table>
</div>
</td>
<td>
    <table>
<tr>
<td  align="right">地区代码:</td><td align="left"><input class="input_M3" id="districtCode" type="text"/></td>
</tr>
<tr>
<td  align="right">地区名称:</td><td align="left"><input class="input_M3" id="districtFullName" type="text"/></td>
</tr>
<tr><td>&nbsp;&nbsp;</td></tr>
<tr>
<td></td>
<td align="right">
<input name=""  id="disser" type="button" class="button_blue" value="查   询"  />
</td>
<tr>
</table>
</td>
<tr class="bottom_bg">
<td ></td>

<td align="right">
<input name=""  id="disadd" type="button" class="button_blue" value="保  存"  />&nbsp;&nbsp;
<input name=""  id="disnot" type="button" class="button_blue" value="取  消"  />
</td>
</tr>
</table>
大约3000多条数据,有点慢.用json最慢了,不想刷新……灰常不想用用iframe,求大神指点

解决方案 »

  1.   

    要实现的功能是什么? 从XML里面读取3000出来显示在页面上? 还是根据界面上的3000条数据做为条件判断把对应的值 放在上面图的右边?
      

  2.   

    可以换种思路,不取ID也是可以的,要取ID就循环去拼接取<!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>
        <title></title>
        <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
        <script>
            $(function () {
                $("table tr").each(function () {
                    var num1 = $(this).find("td:nth-child(1)").text();
                    var num2 = $(this).find("td:nth-child(2)").text();
                    $(this).find("td:nth-child(3)").text(parseFloat(num1 * num2));
                });
                 
            });    </script>
    </head>
        <body>
            
            <table>
                <th>第一列</th><th>第二列</th><th>求和</th>
                <tr>
                    <td>5</td>
                    <td>2</td>
                    <td></td>
                </tr>
                <tr>
                    <td>3</td>
                    <td>2</td>
                    <td></td>
                </tr>
                <tr>
                    <td>2</td>
                    <td>2</td>
                    <td></td>
                </tr>
            </table>
            输出结果为:
            <p id="result">
                第一列 第二列 求和
                5  2  10
                3  2  6
                2  2  4
            </p>
        </body>
    </html>
      

  3.   

    首先一点,原则上id是唯一的。。<tr id="disTR">改为<tr id='${dis.districtCode}'>
    <!-- <td id="${dis.districtCode}"> 的id去掉-->
    js方法改为$('#disser').click(function(){
        var code = $('#districtCode').val().trim();
        $("tr").hide();
        $("tr[id^='" + code + "']").show();
    });
    ..试试会不会快一点,不过你要从3000条数据里面"tr[id^='" + code + "']"这样去取。。肯定是慢的
      

  4.   

    @@应该再加个table限定,漏了。distable
    $('#disser').click(function(){
        var code = $('#districtCode').val().trim();
        $("#distable tr").hide();
        $("#distable tr[id^='" + code + "']").show();
    });
      

  5.   

    若不用table  限定的话就是整个页面查找tr标签了,建议再加个变量吧
    $('#disser').live('click',function(){
    var code=$('districtCode').val().trim();
    var MyTR=$('#distable tr');
    MyTR.hide();
    MyTR.find("td[id^="+code+"]").parents().show();
    });