I keep getting a “missing ) after argument list” (on line 1) when debugging my javascript with firebug. I don’t know what is wrong as it seems all parentheses are there.
The function is supposed to place an image that can be clicked to open a lightbox in the div with id “bigPic”.
Here’s the relevant code:
<script type="text/javascript">
function addContent(divId,filePath,comment) {
document.getElementById(divId).innerHTML = "<div align=\"center\"><a href="+filePath+" title="+comment+" rel=\"lightbox\"><img src="+filePath+" alt="+comment+" style=\"max-height:270px;max-width:410px;\"/></a></div><div id="+comment+" align=\"center\" style=\"font-family:Verdana;margin-top:-13px;color:white;background-color:#07396B;\"><p>"+comment+"</p></div> ";
}
</script>
...
<div width="420px" height="320px" id="bigPic" name="bigPic">
<img src="http://www.villa-gloria-katouna.com/Pool%20viewsmall.JPG" />
</div>
...
echo "<div align=\"center\" style=\"display:inline; overflow:hidden;\"><img src=\"pics/$file\" style=\"cursor:pointer;cursor:hand;\" alt=\"$file\" height=\"30px\" width=\"30px\" onclick=\"addContent('bigPic', $file, $comment);\"/></a></div> ";
I think you forgot quote characters around “$file” and “$comment” in the “onclick” handler code.
I don’t know PHP so that may or may not be the way to get quotes in the “onclick” string, but they need to be there. Otherwise if the comment is “hello world” that’ll expand to
which is clearly incorrect.