Hi Everyone,
Before I post my code…
All I really need to know is how to refresh the content of a <div> tag during runtime with JavaScript. I will have “next” and “previous” links on a <div> layer and when they are clicked, my JS function will assign the right ‘src=“”’ to an <img> tag. How can I refresh only the <div> element and not the whole page ?
I guess I could try ‘Lightbox’ if this is too complicated…
Here is an image to make you understand it better :
I have a page with a <div> layer which is hidden when the page is loaded, and then on the main page content, I have some thumbnails of full size images which I generate with php gd.
The code and link of each generated thumbnail on the main page :
<a href="#" onclick="image_show('{$product.img.type1[images_1].name}');" title="View the full size image"><img border="0" src="{$domain}/includes/crop.php?img_name={$product.img.type1[images_1].name}&setw=100&img_type={$product.img.type1[images_1].type}"></a>
Then the JavaScript function named ‘image_show();’ :
<script type="text/javascript">
<!--
function image_show(img_name)
{
var sw = screen.width;
var sh = screen.width;
document.getElementById('image_tag').src = '../uploads/' + img_name;
document.getElementById('image_full').style.width = sw - 25 + 'px';
document.getElementById('image_full').style.display = "block";
slowly.fade('main');
}
-->
</script>
And atlast the code of the hidden <div> tag which is made visible by the JavaScript function :
<div id="image_full" align="center" style="display:none ; position:absolute ; top:50px ; width:1024px ; z-index:99">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<div style="background-color:#FFFFFF ; padding:5px">
<img style="border:2px #999999 solid" id="image_tag" src="" alt="Image" /><br/><br/>
<a href="#" onclick="image_hide();" class="textblue_links" title="Close this image.">
<img src="{$domain}/images/buttons/close.gif" border="0" alt="Close" /></a>
</div>
</td>
</tr>
</table>
</div>
Sorry for all the code. It’s all pretty straight forward, and it all works perfectly fine, but I was hoping to implement “next” and “previous” links on the hidden div which is made visible to load the next and previous images in my array. I can set the <img> src but the problem is, how do I refresh the <div> element’s content ?
Thanks in advance for any help!!! It will be majorly appreciated.
All the best,
Contrid.