How To Make Search Results "clickable"
Using this to return a list of items that match the search term: if (mysql_num_rows($result) > 0){ while($row = mysql_fetch_object($result)){ $string .= '&
Solution 1:
I'm sure about the server side syntax, please correct it if I made any syntactical mistakes.
It is easy if you an do minor changes to the result html, like wrap each item in a div
$string .= "<div class='item' data-latitude='".$row->lat."' data-longitude='".$row->lng."'><b>".$row->container."</b>"." --- ";
$string .= " yard: ".$row->lot."";
$string .= " -- latitude: ".$row->lat."";
$string .= " -- longitude: ".$row->lng."<br />";
$string .= "</div>";
then
$(document).ready(function(){
$("#search_results").slideUp();
$("#search_button").click(function(e){
e.preventDefault();
ajax_search();
});
$("#search_term").keyup(function(e){
e.preventDefault();
ajax_search();
});
$("#search_results").on('click', '.item', function(){
var $this = $(this);
var lat = $this.data('latitude');
var long =$this.data('longitude');
alert(lat + long)
})
});
Post a Comment for "How To Make Search Results "clickable""