在一个php页面中有个table,可以复选多行,选定后点击确定按钮弹出新的页面,新php页面中显示选中的数据,请教如何实现使用php+js方式

解决方案 »

  1.   


    点击的数据相当于一个json数据串
    我就是不知道则么传递着串,求代码
      

  2.   

    你的意思就是提交带有复选框的表单,是不是? 你可以这样写:
    <input type="checkbox" value="1"  name="info[]">注册步骤太多接收页面获取info参数值就可以了。注意用post方式。
      

  3.   


    是table
    在页面1中
    <table id="tbl_list" ></table>
    然后通过js给其赋值
    $(function(){
    $('#tbl_list').datagrid({..singleSelect:false..})之后选择多行后点击确定按钮需要打开新的页面并且显示刚刚选中行的内容,也是在新页面的table中显示
      

  4.   

    1,可以在打开窗口时通过查询字符串(如 new.php?id=1&type=g )来传递,
    在new.php 用类似 request.querystring("id") 这种方式接收2,可以在打开新窗口的时候,用form,post提交,
    如<form action="new.php" method="post" >
    <input name="id" >
    <input name="type">
    <input type=submit>
    </form>
    在新窗口,用类似 request.form("id") 这种方式来接收,
    这种好处是可以传送大量数据3,如果是原页面和新页面是同域,两页面可以直接相互访问DOM如1.htm 源文件 <table id="table1">
     <tr>
     <td> hello</td><td><input type="checkbox" /></td>
     </tr>
     <tr>
     <td> world</td><td><input type="checkbox" /></td>
     </tr>
     <tr>
     <td> mydear</td><td><input type="checkbox" /></td>
     </tr>
     </table>
     
     
     <input type="button" value="open new window" onclick="window.open('2.htm','','width=400,height=300,status=yes')" />在2.htm可以直接访问1.htm里的任意元素,如
    2.htm源代码如下 <input type="button" value="get checked" onclick="getchecked()"  />
     <script type="text/javascript" >
         function getchecked() {
           
             if (window.opener && window.opener.document.getElementById("table1")) {
                 alert(window.opener.document.getElementById("table1").getElementsByTagName("TR").length);
                 var otrs = window.opener.document.getElementById("table1").getElementsByTagName("TR");
                 for (var i = 0; i < otrs.length; i++) {
                     alert(otrs[i].cells[1].getElementsByTagName("INPUT")[0].checked);
                     if (otrs[i].cells[1].getElementsByTagName("INPUT")[0].checked) {
                        // alert(otrs[i].cells[0].innerHTML);
                     }
                 }
             }
          } </script>
     
    这种好处是
    a,可以访问任意dom元素,不限于form input 或者查询字符串,
    b,可以在打开页面以后随时访问原页面的最实时的情况。这在两个窗口经常要相互交互的时候特别有用。
      

  5.   


    这样对于正常table确实没问题,但我的table是通过$('#tbl_list').datagrid({生成的,没有“TR”标签
    window.opener.document.getElementById("table1").getElementsByTagName("TR");
    这句如果换成datagrid改怎么写?刚刚开始学习js请指教