简体   繁体   中英

On clicking the form divert to another PHP page with the results of the check box

I have a set of check boxes on one page and submit button with value="compare" is out of the form. I have written a jQuery for the button compare outside of the form. I am comparing a set of tables side by side. My code works fine in the same Page. I don't know how to display the result in another page. Anyone please help me.

<?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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM