hi
I’ve been playing around with a module and snippet. So far I’ve got the module to store info into a Db and the snippet to display the list of Db records.
Now, in the list that’s displayed i have 2 links (1 image and 1 text). In the html img tags I want to use the ’onclick’ event to run a javascript function which will update the Db by 1 count (yes, a click counter). I would also like to update the count on the same record if the text link is clicked.
I can get the ’onclick’ event to display an ’alert’ msg but can’t work out how to get the id value of the Db record that the image file name is stored.
I had a go with a few diffrent attempts including this:
//from snippet
<a href="'.$am_link.'"><img src="'.$am_img.'" id="'.$am_rec_id.'" onclick="Amhit()" border="0" alt="" ></a>
// javascript in external file
function Amhit('.$am_rec_id.')
{
var recid=document.getElementById('.$am_rec_id.').innerHTML;
alert("you clicked on rec id!" + recid.innerHTML );
}
but nothing seems to work except the basic alert msg.
I should mention that I’m new to javascript, although, it does seem quite similar to php, I just can’t figure this out.
any help or advice is much appreciated