Hello everyone on Easter morning...
Take the record number of the clicked row and pass that value to a new php script [displayRec.php]
, and load the record for display, edit & save, or delete. Ideally, I would like the new window to overlay the window of the clicked row, and when work is done, return to the previous window for another selection.
I tried AJAX [ajax_post( )]
to transfer the value of keyid to displayRec.php
but without success, and that code has broken the original script. Some AJAX response code is present for testing purposes, but that is not needed.
The modified script
- Why did ajax_post() break the original script?
- Using js, how do I execute displayRec.php while passing keyid?
The script, displayRec.php:
var tbl = document.getElementById("myTable");
var trs = tbl.rows;
for ( var t = 0; t < trs.length; ++t )
var tr = trs[t]; // one row
if ( tr.id.substring(0,3) == "ROW" )
tr.onclick = pickRow;
function pickRow( )
var keyid = this.id.substring(3); // get the ID of the <tr> past the "ROW"
alert( "You clicked on the row with keyid " + keyid );
function ajax_post( )
var ajax = ajaxObj("POST", "displayRec.php");
ajax.onreadystatechange = function()
if(ajaxReturn(ajax) == true)
//document.getElementById("status").innerHTML = response;
ajax.send("keyid=" . keyid );
//<!-- ******** displayRec.php ******** -->
echo $_POST["keyid"]." is ".$_POST["keyid"];
echo "displayRec worked!";
As always, I want to understand the fix so please explain your suggestions in detail, and theory, concepts, and references are always welcome.
Thanks again and happy Easter