Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从v列表中进行值匹配_Php_Html_Css - Fatal编程技术网

Php 从v列表中进行值匹配

Php 从v列表中进行值匹配,php,html,css,Php,Html,Css,我如何制作一个简单的脚本,从列表中找到相同的值并突出显示它们! 为了清楚起见,我有参数(带有复选框的值),当我单击一个或多个复选框时,我希望脚本找到相同的值,并从值列表中高亮显示(或为单元格着色)。有人能给我一个想法如何做到这一点,请或如果你知道一个类似的脚本,这将是有益的。我知道基本的html/css/php/mysql 无标题文件 参数: x Y Z Q xy 价值观: x Z Z Y Q Q Y Y Q Z x Y Z Y x Q Q xy Z xy Z Y Z Y Z Z 也许

我如何制作一个简单的脚本,从列表中找到相同的值并突出显示它们! 为了清楚起见,我有参数(带有复选框的值),当我单击一个或多个复选框时,我希望脚本找到相同的值,并从值列表中高亮显示(或为单元格着色)。有人能给我一个想法如何做到这一点,请或如果你知道一个类似的脚本,这将是有益的。我知道基本的html/css/php/mysql


无标题文件
参数:
x
Y
Z
Q
xy

价值观: x Z Z Y Q Q Y Y Q Z x Y Z Y x Q Q xy Z xy Z Y Z Y Z Z



也许这就是你要找的。请注意,在CSS和底部的
jQuery
库和
部分添加了
高亮显示

<!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>Untitled Document</title>
<style type="text/css">
<!--
body  {
    font: 100% Verdana, Arial, Helvetica, sans-serif;
    background: #666666;
    margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
    padding: 0;
    text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
    color: #000000;
}
.twoColLiqLt #container {
    width: 80%;  /* this will create a container 80% of the browser width */
    background: #FFFFFF;
    margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
    border: 1px solid #000000;
    text-align: left; /* this overrides the text-align: center on the body element. */
}

/* Tips for sidebar1:
1. since we are working in percentages, it's best not to use padding on the sidebar. It will be added to the width for standards compliant browsers creating an unknown actual width.
2. Space between the side of the div and the elements within it can be created by placing a left and right margin on those elements as seen in the ".twoColLiqLt #sidebar1 p" rule.
3. Since Explorer calculates widths after the parent element is rendered, you may occasionally run into unexplained bugs with percentage-based columns. If you need more predictable results, you may choose to change to pixel sized columns.
*/
.twoColLiqLt #sidebar1 {
    float: left;
    width: 24%; /* since this element is floated, a width must be given */
    background: #EBEBEB; /* the background color will be displayed for the length of the content in the column, but no further */
    padding: 15px 0; /* top and bottom padding create visual space within this div  */
}
.twoColLiqLt #sidebar1 h3, .twoColLiqLt #sidebar1 p {
    margin-left: 10px; /* the left and right margin should be given to every element that will be placed in the side columns */
    margin-right: 10px;
}

/* Tips for mainContent:
1. the space between the mainContent and sidebar1 is created with the left margin on the mainContent div.  No matter how much content the sidebar1 div contains, the column space will remain. You can remove this left margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends.
2. to avoid float drop at a supported minimum 800 x 600 resolution, elements within the mainContent div should be 430px or smaller (this includes images).
3. in the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs.
*/
.twoColLiqLt #mainContent {
    margin: 0 20px 0 26%; /* the right margin can be given in percentages or pixels. It creates the space down the right side of the page. */
}

/* Miscellaneous classes for reuse */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
    float: right;
    margin-left: 8px;
}
.fltlft { /* this class can be used to float an element left in your page */
    float: left;
    margin-right: 8px;
}
.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
    clear:both;
    height:0;
    font-size: 1px;
    line-height: 0px;
}
.highlight {background:#f00;}
-->
</style><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.twoColLiqLt #sidebar1 { padding-top: 30px; }
.twoColLiqLt #mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]--></head>

<body class="twoColLiqLt">

<div id="container">
  <div id="sidebar1">
    <h3>Parameters:</h3>
    <form id="form1" name="form1" method="post" action="">
      <label>
      <input type="checkbox" name="x" id="x" />
        x</label>
      <label>
      <input type="checkbox" name="y" id="y" />
      y</label>
      <label>
      <input type="checkbox" name="z" id="z" />
      z</label>
      <label>
      <input type="checkbox" name="q" id="q" />
      q</label>
      <label>
      <input type="checkbox" name="xy" id="xy" />
      xy</label>
    </form>
    <p>&nbsp;</p>
    <!-- end #sidebar1 --></div>
  <div id="mainContent">
    <h1>Values:</h1>
    <table width="611" height="129" border="1">
      <tr>
        <td>x</td>
        <td>&nbsp;</td>
        <td>z</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>z</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>y</td>
        <td>q</td>
        <td>q</td>
        <td>&nbsp;</td>
        <td>y</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>y</td>
        <td>q</td>
        <td>&nbsp;</td>
        <td>z</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>x</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>y</td>
        <td>z</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>y</td>
        <td>x</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>q</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>q</td>
        <td>&nbsp;</td>
        <td>xy</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>z</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>xy</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>z</td>
        <td>y</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>z</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>y</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>z</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>z</td>
      </tr>
    </table>
    <p>&nbsp;</p>

    <!-- end #mainContent --></div>
    <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />
<!-- end #container --></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
    $('#form1 input[type="checkbox"]').on('click',function(e) {
        var val = $(this).attr('name');
        $('#mainContent table td').removeClass('highlight');
        $('#mainContent table td').each(function( index ) {

            if ( $( this ).text() == val ) {
                $( this ).addClass('highlight');
            }
        });
    });
</script>
</body>
</html>

无标题文件
参数:
x
Y
Z
Q
xy

价值观: x Z Z Y Q Q Y Y Q Z x Y Z Y x Q Q xy Z xy Z Y Z Y Z Z


$(“#form1 input[type=“checkbox”]”)。在('click',函数(e)上{ var val=$(this.attr('name'); $('#mainContent table td').removeClass('highlight'); $('#mainContent table td')。每个(函数(索引){ if($(this).text()==val){ $(this.addClass('highlight'); } }); });
你能提供你正在研究的代码吗?你能编辑你的问题并把代码放在那里吗?我想现在我已经做到了。因此,为了实现这一点,我认为你应该熟悉
jQuery
谢谢@Michal,但我对jQuery一无所知,也不知道从哪里开始。也许有一种替代jquery的方法?是的,这就是我想要的。但这里有两个问题;当我取消单击时,它仍然保持高亮显示,并且不会同时高亮显示两个以上的参数。是的,这不是一个完整的解决方案。但我只是想向您展示如何通过
jQuery
实现这一点。当然,您也可以使用php进行同样的操作,但这将更加复杂。试着玩一下这个,根据你的需要改变它。谢谢@Michal。我会尽力去做的。