use PHP with Javascript question
Posted: Sun Mar 09, 2003 10:56 pm
A web page written in PHP (foo.php) and a link in the page is:
<a href="#" onClick="record_12history_hitrate()">........
the function record_12history_hitrate() is defined on the top of the page as the following:
<script language="JavaScript">
<!--
function record_12history_hitrate()
{
//open a new window to display another page
window.open('./activity.php?activity_id=30', '12history');
//record this hit into db
// connectDB() and record_12history_hitrate() are both php function
//defined my self, the former is used to connect mysql db, the latter is
// used to write the data into db
document.writeln("<?php connectDB(); record_12history_hitrate(); ?>");
}
My question is: the new page could be opened, and the db could be written. But after each hit the link, the original page foo.php became
blank, it seemed that something is wrong, so, what's the reason or somebody has good other idea to implement it??
<a href="#" onClick="record_12history_hitrate()">........
the function record_12history_hitrate() is defined on the top of the page as the following:
<script language="JavaScript">
<!--
function record_12history_hitrate()
{
//open a new window to display another page
window.open('./activity.php?activity_id=30', '12history');
//record this hit into db
// connectDB() and record_12history_hitrate() are both php function
//defined my self, the former is used to connect mysql db, the latter is
// used to write the data into db
document.writeln("<?php connectDB(); record_12history_hitrate(); ?>");
}
My question is: the new page could be opened, and the db could be written. But after each hit the link, the original page foo.php became
blank, it seemed that something is wrong, so, what's the reason or somebody has good other idea to implement it??