各位大侠帮帮忙:
   J2EE,
   在进入查询结果页面后,页面会显示多行数据,每行末尾处有个计算按钮(数据均通过查询的条件从数据库获得,不固定的),点击某行的计算按钮,想要获得这行上某个数据并将其传到后台Action中,应该怎么做?按钮应该做什么特别的设计????

解决方案 »

  1.   

    <!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">
    function getInf(a){
    var p=a.parentNode;
    var sib=p.previousSibling;
    if(sib.tagName!='Td'){
    sib=sib.previousSibling;
    }
    window.location.href="http://www.baidu.com/s?w="+sib.innerHTML;
    }
    </script>
    </head><body>
    <table>
    <tr>
         <td>是</td>
            <td><input type="button" onclick="getInf(this)" value="test"></td>
        </tr>
        <tr>
         <td>阿达</td>
            <td><input type="button" onclick="getInf(this)" value="test"></td>
        </tr>
        <tr>
         <td>问</td>
            <td><input type="button" onclick="getInf(this)" value="test"></td>
        </tr>
        <tr>
         <td>我打</td>
            <td><input type="button" onclick="getInf(this)" value="test"></td>
        </tr>
        <tr>
         <td>啊大大</td>
            <td><input type="button" onclick="getInf(this)" value="test"></td>
        </tr>
        <tr>
         <td>挖到</td>
            <td><input type="button" onclick="getInf(this)" value="test"></td>
        </tr>
    </table>
    </body>
    </html>
    这样?至于把值传到action里如果不想跳转页面的话可以用alax试试
      

  2.   

    +1如果要用ajax那得注意了,因为ajax的跨域访问是比较麻烦的。