I am currently having issues with making buttons based on an array of information on customers. I have made the buttons in the following way:
foreach($array as $row)
{
echo (
"<tr>".
"<td>".$row['last_name']. "</td>".
"<td>".$row['first_name']. "</td>".
"<td>".$row['phone_no']. "</td>".
"<td>".$row['date_of_birth']. "</td>".
"<td>".$row['membership']. "</td>".
"<td><Button class='resultBookButton' data-lastName=".$row['last_name']." data-firstName=".$row['first_name']." data-phone=".$row['phone_no'].">Reserve</Button></td>".
"</tr></table>");
}
Above my PHP script I have the following:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
// Handling search results
$('.resultBookButton').click(function(e){
// Get the name of the user clicked
var lastName = $(this).data("lastName");
var firstName = $(this).data("firstName");
var phoneNum = $(this).data("phone");
window.location = "ss reservation.php?lastName=" + lastName + "&firstName=" + firstName + "&phoneNum=" + phoneNum;
});
});
</script>
What I want to achieve is being able to open a php page with the parameters lastName, firstName, and phoneNum. I have not seen any GET methods on how to do this in javascript except for AJAX. But ajax keeps you on the same page, and is not what I am looking for.
Any suggestions?