Forum Moderators: open
I'm using the Javascript Image Gallery from A List Apart which is working fine.
I need to get the filename for the currently selected main image from javascript into PHP and I can't work out how to do it. I'm OK with PHP but rather a beginner at Javascript so I suspect it's a simple job.
The script code is:
<script type="text/javascript" language="javascript">
function showPic (whichpic) {
if (document.getElementById) {
document.getElementById('placeholder')»
.src = whichpic.href;
if (whichpic.title) {
document.getElementById('desc')»
.childNodes[0].nodeValue = whichpic.title;
} else {
document.getElementById('desc')»
.childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
}
return false;
} else {
return true;
}
}
</script>
and the link code for selecting an image is:
<ul>
<li><a onclick="return showPic(this)" href="images/bananas.jpg" title="A bunch of bananas on a table">some bananas</a></li>
<li><a onclick="return showPic(this)" href="images/condiments.jpg" title="Condiments in a Chinese restaurant">two bottles</a></li>
<li><a onclick="return showPic(this)" href="images/shells.jpg" title="Seashells on a table">some shells</a></li>
</ul>
As I see it I need to make the value of 'whichpic.href' available to my PHP code.
Can anyone help?
So the client clicks a thumbnail and gets a large version of the image with a link under it that says 'Order Print'. I need that link to pass the selected image number to the PHP cart script, but I can't work out how to get the variable 'whichpic.href' out of the javascript and into my PHP hyperlink.
Hope that makes sense!