0

我在一个表中有一个带有 mikrotikm(router) nat 规则的大列表,现在我想要一个动态搜索过滤器来从名称中搜索列表,如下所示:

演示

我尝试使用他们的代码但不起作用。

我使用其他代码但不工作..

这是完整的代码:

<html>
<head>
<script type='text/javascript' language='javascript' defer>
$("#search").on("keyup paste", function() {
    var value = $(this).val().toUpperCase();
    var $rows = $("table tr");

    if(value === ''){
        $rows.show();
        return false;
    }

    $rows.each(function(index) {
        if (index !== 0) {

            $row = $(this);

            var column1 = $row.find("td:first a").html().toUpperCase();
            var column2 = $row.find("td").eq(1).text().toUpperCase();

            if ((column1.indexOf(value) > -1) || (column2.indexOf(value) > -1)) {
                $row.show();
            }
            else {
                $row.hide();
            }
        }
    });
});
</script>

<style type='text/css'> 
table tr td{
border:1px solid #000
}
</style>

</head>
<body>
    <label for="search">Search:</label> <input type="text" id="search" value=""/>


<?php
use PEAR2\Net\RouterOS;
// require_once 'pear2\src\PEAR2\Autoload.php';
require_once 'PEAR2_Net_RouterOS-1.0.0b4.phar';

//Conexion a Mikrotik
                            //IP MIKROTIK   //Usuario   //Password
$client = new RouterOS\Client('62.82.4.222', 'victor', 'victor');




//Reiniciar PPP

$remove=new RouterOs\Request("/ppp/active/remove");
$remove->setArgument('numbers', $itemID); 


// Tabla
echo "<table align='center' id='natlist'><form action='' method='POST'>";
echo "<thead><tr bgcolor='#D8D8D8'><th align=left size=3>Nombre</th><th align=left size=3>Servicio</th><th size=3>Tiempo Activo</th><th align=left size=3>Direccion</th><th align=left size=3>Reiniciar</th></tr></thead><tbody>";

//Actualizar pagina
//echo "<meta http-equiv='refresh' content='30'>";


$ppps = $client->sendSync(new RouterOS\Request('/ppp/active/print'))->getAllOfType(RouterOS\Response::TYPE_DATA);



$interfaceQuery = RouterOS\Query::where('name', $ppps->getArgument('name'));
while ($ppp = $ppps->next()) {
    $interfaceQuery->orWhere('name', $ppp('name'));
}

$activeInterfaces = $client->sendSync(new RouterOS\Request('/interface/pppoe-server/print', $interfaceQuery))->getAllOfType(RouterOS\Response::TYPE_DATA)->toArray();


foreach ($ppps as $ppp) {
  $id = $ppp('.id');
  $service = '';
  foreach ($activeInterfaces as $index => $pppInterface) {
    if ($pppInterface('name') === $ppp('name')) {
      $service = $pppInterface('service');
      break;
    }
 }
  echo "<tr>";
 echo "<td class='nombre'>". $ppp('name') ."</td>";
  echo "<td>" . $service . "</td>";
  echo "<td>" . $ppp('uptime'). "</td>";
  echo "<td>". $ppp('address') ."</td>"; 
  echo "<td><button type='submit' value='{$id}' name='act[remove]' >Reiniciar</td></tr>";
} 

echo  "</form></tbody></table>";

?>

</body>
</html>
4

1 回答 1

1

使用Jquery数据,简单易实现。

于 2013-10-30T12:11:01.167 回答