How To Link To Another Php Page Using Onclick Event From Javascript?
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) {
Solution 1:
Why do you need JavaScript at all for this? Why don't you create a normal link which also works if JavaScript is disabled?
<?phpforeach($arrayas$row): ?><tr><td><?phpecho$row['last_name'] ?></td><td><?phpecho$row['first_name'] ?></td><td><?phpecho$row['phone_no'] ?></td><td><?phpecho$row['date_of_birth'] ?></td><td><?phpecho$row['membership'] ?></td><td><aclass='resultBookButton'href="<?php printf("ssreservation.php?lastName=%s&firstName=%s&phoneNum=%s", $row['last_name'], $row['first_name'], $row['phone_no']) ?>"
>Reserve</a></td></tr><?phpendforeach; ?>
If you want the appearance of a button, you can use CSS to style the link as button:
a {
color: black;
padding: 5px;
border: 2px outset lightgrey;
background-color: lightgrey;
text-decoration: none;
}
a:active {
border-style: inset;
}
Solution 2:
try this..
window.location.href = "ss reservation.php?lastName=" + lastName + "&firstName=" + firstName + "&phoneNum=" + phoneNum;
Post a Comment for "How To Link To Another Php Page Using Onclick Event From Javascript?"