0

我在一个页面上有一组复选框,并且 value="compare" 的提交按钮不在表单中。我已经为表单之外的按钮比较编写了一个 jQuery。我正在并排比较一组表格。我的代码在同一个页面中运行良好。我不知道如何在另一个页面中显示结果。任何人请帮助我。

<?php
require('db.php');


?>


<!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>Comparision</title>
</head>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script type="text/javascript"> 
$(document).ready(function(){
    $("#compare_id").click( function(){
$("input:checkbox:not(:checked)").each(function() {
    var column = "table ." + $(this).attr("name");
    $(column).hide();
});
    });
});
$(document).ready(function(){
    $("#compare_id").click( function(){
$("input:checkbox:(:checked)").each(function(){
    var column = "table ." + $(this).attr("name");
    $(column).toggle();
});
    });
});


</script>
</head>
<body>
<input name="compare" id="compare_id" type="button" value="Compare"  />

<form  action="test.php"  method="post" name="printers_comparision">
  <p>
    <label>
      <input type="checkbox" name="p1" value="Printer1" id="CheckboxGroup1_0" />
      Printer1</label>

    <label>
      <input type="checkbox" name="p2" value="Printer2" id="CheckboxGroup1_1" />
      Printer2</label>

    <label>
      <input type="checkbox" name="p3" value="Printer3" id="CheckboxGroup1_2" />
      Printer3</label>

    <label>
      <input type="checkbox" name="p4" value="Pritner4" id="CheckboxGroup1_3" />
      Printer4</label>

    <label>


</form>
<table width="1023" border="1">
  <tr>
    <td width="193"></td>
    <td class="p1" width="113"><img src="images/im.png"/></td>
    <td class="p2" width="67"><img  src="images/im.png"/></td>
    <td class="p3" width="67"><img  src="images/im.png"/></td>
    <td class="p4" width="67"><img  src="images/im.png"/></td>
</tr>
<tr>
  <td>Title</td>
    <td class="p1" >Printer1</td>
    <td class="p2" >Printer2</td>
    <td class="p3" >Printer3</td>
    <td class="p4" >Printer4</td>
</tr>
<tr>
    <td>Manufacturer</td>
    <td class="p1" ><?php $query=mysql_query('select Manufacturer from printers where printers_id="1";');
while($row=mysql_fetch_array($query)) echo $row['Manufacturer'] ?></td>
    <td class="p2" ><?php $query=mysql_query('select Manufacturer from printers where printers_id="2";');
while($row=mysql_fetch_array($query)) echo $row['Manufacturer'] ?></td>
    <td class="p3" ><?php $query=mysql_query('select Manufacturer from printers where printers_id="3";');
while($row=mysql_fetch_array($query)) echo $row['Manufacturer'] ?></td>
    <td class="p4" ><?php $query=mysql_query('select Manufacturer from printers where printers_id="4";');
while($row=mysql_fetch_array($query)) echo $row['Manufacturer'] ?></td>
</tr>
</body>
</table>
</table>
4

1 回答 1

1

如果需要跨页面显示数据,您可以尝试使用SESSION变量或设置COOKIE

于 2013-03-15T15:12:09.877 回答