my html:
<form action="submitPage.php" method="post" onsubmit="savePathInVar();">
<table>
<tr>
<td><img src="<?php echo $path; ?>" onclick="changecolor(this);" /></td>
<td><img src="<?php echo $path; ?>" onclick="changecolor(this);" /></td>
</tr>
<input type="hidden" value="ClickedImaged" />
<input type="submit" value="Submit" />
</table>
</form>
ps: $path = "inventory_images/$id.jpg";
my function changecolor():
function changecolor(img)
{
var images = document.getElementsByTagName("img");
for(var i=0,j=images.length; i<j; i++)
{
images[i].style.borderColor="#000";
}
img.style.borderColor="#F00";
//Operate on img location as before
savePathInVar(img.src);
}
my function savePathInVar():
function savePathInVar(ImgLocation)
{
//How do i save the path of the clicked image in a variable now?
}
How do i save the path of the clicked image in a variable now?
And how do i get this variable into my input-hidden-field below my table?
Anyone who can help me?
would be really nice if anyone could help me.. i am quite new to javascript :) greetings!