There is a live search form (liveserarch)

<div id="lscontainer"> <div class="starter-template-purple"> <div class="page-header"> Живой телефонный справочник<sup style="color: tomato; vertical-align: top;">&beta;</sup> </div> <form role="form" method="post"> <div class="form-group"> <input type="text" class="form-control" id="keyword" placeholder="Введите слово..." autocomplete="off"> </div> <div class="form-group"><center> <table style="width: 80%;"> <tr> <td width="33%"><input type="radio" name="search_type" value="by_address" id="radio4" class="css-checkbox" checked="checked" /> <label for="radio4" class="css-label radGroup2">по адресу </label> </td> <td width="34%"><input type="radio" name="search_type" value="by_name" id="radio5" class="css-checkbox" /> <label for="radio5" class="css-label radGroup2">по фамилии </label> </td> <td width="33%"><input type="radio" name="search_type" value="by_phone" id="radio6" class="css-checkbox" /> <label for="radio6" class="css-label radGroup2">по телефону </label> </td> </tr> </table> </center></div> </form> </div> </div> 

and JavaScript to which the POST method is sent the value of input (id = "keyword") for search.clients.inc.php

 <script type="text/javascript"> $(document).ready(function() { $('#keyword').on('input', function() { var searchKeyword = $(this).val(); if (searchKeyword.length >= 3) { $.post('search.clients.inc.php', { keywords: searchKeyword }, function(data) { $('div#content-ls').empty() $.each(data, function() { $('div#content-ls').append('<div class="boxer-lte"> <span class="box2"><b>' + this.db_name + ',</b> ' + this.db_address + '</span> <span class="box3">' + this.db_phones + '' + this.db_district + '<span> </div>'); }); }, "json"); } }); }); </script> 

Question: how to modify the JavaScript code so that it sends to the search.clients.inc.php also the selected radio values.

http://www.finalwebsites.com/jquery-ajax-live-search/

    1 answer 1

     var searchKeyword = $(this).val(); var searchBy = $('input[name="search_type"]:checked').val(); if (searchKeyword.length >= 3) { $.post('search.clients.inc.php', { keywords: searchKeyword, searchType: searchBy }, function(data) { ...