0

I have a table which echos a button, currently this button takes you to the 'details.php' with £booking_id record taken over to the new php scrpit. Here is my current code:

echo '<td>a href="Details.php?id='.$row['booking_id'].'"><button>View Details</button></td>';

I would like this button to open a new popup window. How do i merge the two together, so when i click the button the popup window and takes the 'booking_id' record over. i have the java script code:

<script type="text/javascript">
// Popup window code
function newPopup(url) {
    popupWindow = window.open(
        url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
</script>
<a href="JavaScript:newPopup('Details.php);">View Details</a>

2 Answers 2

1
echo '<td>';
echo '<input type="button" value="View Details" onclick="JavaScript:newPopup(\'Details.php?id='.$row['booking_id'].'\')" />';
echo '</td>';
Sign up to request clarification or add additional context in comments.

Comments

0

INDEX.PHP

<html>
<head><title>No Head</title></head>
<body>    
<?php    
$rows = array(
    0 => array('booking_id' => 1),
    1 => array('booking_id' => 2),
    2 => array('booking_id' => 3),
    3 => array('booking_id' => 4),
);    
echo '<table>';
foreach($rows as $row)
{
    echo "\n<tr><td>";
    echo '<a href="Details.php?id=' . $row['booking_id'] .'"';
    echo ' onclick="javascript:popup(this.href); return false;">';
    echo 'View Details';
    echo '</a>';
    echo "</td></tr>";
}
echo "\n</table>";
?>    
</body>
<script type="text/javascript">
function popup(url) {
    popupWindow = window.open( url, 'popUpWindow',
        "height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes"
    )
}
</script>
</html>

DETAILS.PHP

<html>
<head></head>
<body>
Details for ID <?php echo $_GET['id']; ?>
</body>
</html>

3 Comments

You havent included the button, also the size of the window needs to be what i specify
The script itself is returning errors, how would iput this together with the script, so that with each record that is echo out. it shows the button and when the button is preessed the popup window is shown
What you accepted as correct was my initial answer. Also my answer provides a full example. Found out that this also solves your question: stackoverflow.com/questions/22616851/… :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.