Как добавить фильтр JQuery в HTML-таблицу

Добавьте это ваш xml: android:autoLink="phone"

0
задан inullpointer 16 January 2019 в 07:59
поделиться

2 ответа

Вы можете использовать AJAX для решения этой задачи.

HTML-код:

<form name="formobject" method="POST" action="">
<input type="hidden" name="formrstatus" value="">
<select class="filter" data-tableId="myTable" onchange="checkValue(this.value)">
  <option value="all">All</option>
  <option value="male">Male</option>
  <option value="female">Female</option>
</select>
</form>

<script>
</script>
function checkValue(id){
$.ajax({
type: "POST",
url:"/someurl",
dataType: 'JSON',
data: {id},
success: function(response) {
                //use this response to fetch table data
},
error: function(XMLHttpRequest, textStatus, errorThrown) {

   }
});
}

/*Use api to fetch the values according to the posted value and return the json encoded value, something like this*/

<?php
$id=encodestring(

Вы можете использовать AJAX для решения этой задачи.

HTML-код:

[110]POST["id"]); $sql="select * from sometable where gender='".$id."'"; $result= $mysqli->query($sql); $vars[] = array($res); echo json_encode($vars); ?>
0
ответ дан Akash 16 January 2019 в 07:59
поделиться
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
    $("#myInput").on("keyup", function() {
      var value = $(this).val().toLowerCase();
      $("#myTable tr").filter(function() {
        $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
      });
    });
  });
</script>
0
ответ дан inullpointer 16 January 2019 в 07:59
поделиться
Другие вопросы по тегам:

Похожие вопросы: