Hi everyone
I'm trying to add a click counter to a list of links that are displayed from a mysql Db.
I have something that works but when the a link is clicked a new window opens to the links destination(which is right
), but then focus is returned to the old window and an alert message displayed with an 'ok' button that needs to be clicked.
I would like to get rid of the alert msg.
Also the js library I'm using is - fleegix.js which I would like to change of mootools.js (since it's already being loaded for other purposes).
This is what I have so far...
Link displayed with link id passed to js via '$am_id' var
js to call the counter.php file
And the counter.php to update the Db
So... does anyone know how to do this with mootools.js or if you have a sugestion for a better way of achiving this your help is much appreciated.
I'm trying to add a click counter to a list of links that are displayed from a mysql Db.
I have something that works but when the a link is clicked a new window opens to the links destination(which is right
I would like to get rid of the alert msg.
Also the js library I'm using is - fleegix.js which I would like to change of mootools.js (since it's already being loaded for other purposes).
This is what I have so far...
Link displayed with link id passed to js via '$am_id' var
| Code: |
| <div class="Tlink">Tx link: <a href="'.$amlink.'" onclick="Amhit('.$am_id.');" target="_blank">'. |
js to call the counter.php file
| Code: |
|
function msg(resp) { alert(resp); } function Amhit(amid) { fleegix.xhr.doGet(msg, 'amcnt.html?amid='+amid, 'text'); } |
And the counter.php to update the Db
| Code: |
|
$amid = $_GET['amid']; if ($amid !=""){ $table = $modx->getFullTableName('am'); $rs = $modx->db->select('clicks', $table, 'id="'.$amid.'"'); $row = $modx->db->getRow($rs); $hits = $row['clicks']; $hit = $hits+1; $modx->db->query("UPDATE $table SET clicks='$hit' WHERE id='$amid' ") or die(mysql_error()); echo "update of record $amid successful!"; } else { echo "update failer!! What - no id!!"; } |
So... does anyone know how to do this with mootools.js or if you have a sugestion for a better way of achiving this your help is much appreciated.
