I have a a grid of images which has it's HTML generated with PHP. Each image has an onclick() function, which has a PHP variable in the arguments. On the page that the HTML is on, I have a Javascript function which uses the arguments in the onclick(arg) function.
I've started to use jquery and I want to be able change this onclick() function into my jquery functions, while using the PHP arguments from the PHP page.
This is the code from the PHP file that generates the HTML, as you can see, there is an onclick function, which would have an argument that is a number:
Echo "<img src= '$link[Image_Link] . /133x100' id='$row[Item_Name]' title='$row[Item_Name]' class='clickableImage' alt='$just_name' onClick='addValue(". $credit_value .")' border=0 style='position: relative; top: 0; left: 0;'/>";
This is my Javascript function on the HTML page, it just changes some text on the page:
function addValue(credits){
var value = document.getElementById("value").innerHTML;
value = parseInt(value, 10);
var totalValue = value+credits;
document.getElementById("value").innerHTML = totalValue;
}
I already have a jquery function set up for when these images are clicked, but I want to be able to use the $credit_value variable from the PHP file. This is the start of my jquery function:
$().ready(function () {
$('img.clickableImage').click(function () {
if ($(this).data('selected')) { ......