Click to See Complete Forum and Search --> : recordset to Javascript
damon2003
12-04-2003, 07:33 AM
Hi,
I have a PHP recordeset that displays several values in a table on a page. I want to get these values and display them in a Javascript popup, how can this be achieved?
thanks
Pittimann
12-04-2003, 07:46 AM
Hi!
Just tell your PHP file to parse the js code for the popup window using the values later displayed in the table as PHP-parsed js variables...
Cheers - Pit
damon2003
12-04-2003, 07:48 AM
Sorry I dont get it,
can you explain a bit more?
thanks
Pittimann
12-04-2003, 07:58 AM
Hold on a bit - I'll start dealing with it in several minutes...
Cheers - Pit
Pittimann
12-04-2003, 08:13 AM
Hi!
Not knowing the structure of your PHP file it is difficult to give you a complete solution. So the code below is just a short example. You can copy the code, paste it into your editor and save it as a PHP file. If you run it afterwards, you will see what it does: the PHP has only one variable (value: "Blah"). The rest is just echoing the js for the popup including the document.write to the popup. "Blah" goes in there as a parsed js variable...
So running that stuff will give you an empty document, a window popping up with just one word - guess which :)
<?PHP
$PHPvar1="Blah";
echo '<script language="JavaScript" type="text/javascript">';
echo 'h = 140;';
echo 'w = 500;';
echo 'h2 = h + 25;';
echo 'w2 = w;';
echo 'LeftPosition = (screen.width) ? (screen.width-w2)/2 : 0;';
echo 'TopPosition = (screen.height) ? (screen.height-h2)/2 : 0;';
echo "WinProps ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition;";
echo "newWin=window.open('','',WinProps);";
echo 'var JSvar1="'.$PHPvar1.'";';
echo 'newWin.document.write("<html><head><title></title></head><body><center><br><br>");';
echo 'newWin.document.write(JSvar1+"</center></body></html>");';
echo '</script>';
?>
Cheers - Pit