I have the following php script
Code: Select all
$img2 = $img2_id.$img2_name;
$img2_thumb = "thumb_".$img2_id.$img2_name;
echo "<div id='viewadd_image2' class='smallimage'><img src='uploads/".$img2_thumb."' onclick = 'display_img($img2)'/></div>";
eg. 102rubberduck.jpg
I then want to pass this variable into a javascript function which allows me to display the image inside a selected DIV
Javascript:
<script type="text/javascript">
function display_img(img)
{
document.getElementById("viewadd_mainimage").innerHTML = "<img class ='image' src='UPLOADS/" + img + "'/>";
}
</script>
The problem i am having is that the variable starts with a number and is therefore creating an error in Javascript.
From mozilla i'm getting the following message:
Timestamp: 1/5/2012 14:57:05
Error: identifier starts immediately after numeric literal
Source File: http://localhost/DuckLa/viewadd.php?id=125
Line: 1, Column: 12
Source Code:
display_img(102Rubber duck.jpg)
Any help would be grand. Thanks in advance,