I am doing a school website project and I hit a rock with a thing that I want to do.
I have a search page that uses Google Places API and searches for nearby places and displays them on the page. The name of every place (restaurant) is a paragraph tag within a link tag that leads to another page that I want to populate with information from the previews page. How can I save whatever the user has clicked in a variable, for example the Restaurant name and use this variable in another page to populate a placeholder "The Restaurant" there.
This is the jQuery code of the search page that populates the search page with results:
for(var i = 0;i<Object.keys(jsondata.results).length;i++){
if(jsondata.results[i].name !== undefined){
if(jsondata.results[i].photos !== undefined){
photoRef = jsondata.results[i].photos[0].photo_reference;
//alert(photoRef);
}
//alert(searchedResultsPhotos);
$(".col-md-7").append("<div><img class=col-md-3 alt=restaunrant_image src="+searchedResultsPhotos+"/>"
+"<a href=RestaurantTemplate.html><p class=restaurant_name col-md-7>"+jsondata.results[i].name+"</p></a></div");
}
}
$(".col-md-7 div").addClass("row");
Here are some screenshots of the site.
Search page:
Restaurant details: