【问题标题】:On clicking the form divert to another PHP page with the results of the check box单击带有复选框结果的表单转移到另一个 PHP 页面
【发布时间】:2017-11-04 17:02:30
【问题描述】:

我在一个页面上有一组复选框,并且 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>

【问题讨论】:

    标签: javascript php jquery html-table comparison


    【解决方案1】:

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

    【讨论】:

    • 这个非常简单。无论如何,每个人都从头开始,所以我会告诉你。要使用会话设置值,请使用:$_SESSION['some_index'] = 'some value'; 要检索此值,您应该使用 $some_var = $_SESSION['some_index'];每个 PHP 文件都应该将session_start() 作为第一行,并且在设置会话之前不应将任何输出发送到浏览器。如果您在理解方面遇到困难,请多问
    • 为了简单起见,你可以看看这2个基础教程1)w3schools.com/php/php_sessions.asp2)w3schools.com/php/php_cookies.asp
    • 我建议您研究一下发送数据(您已经发送)并在 PHP 脚本中接收信息的可能性。这可能会解决问题。
    • 对上述情况真的有效吗?抱歉我没听懂
    • 糟糕...我误读了您的评论。请通过提供的链接。你可以通过这种方式解决你的问题。
    猜你喜欢
    • 2013-07-28
    • 2015-08-15
    • 2011-11-10
    • 1970-01-01
    • 1970-01-01
    • 2013-09-20
    • 1970-01-01
    • 2015-11-24
    • 2016-10-22
    相关资源
    最近更新 更多