dugjason
08-28-2008, 10:48 AM
My javascript function below is written to control the visibility of the "next" and "previous" buttons used to page through an image gallery (eg. showing images 1-10 of 50. press next to show 11-20 etc.)
When I remove the alert("!"); it will no longer hide and show the next/previous buttons as it does with the alert("!"). It does however seems to work OK when I do include the alert("!"), which is a pain as obviously it pops up every time you move to the next page.
javascript Code:
<script type="text/javascript">
function hideShow(x, hv, imgno) {
alert("!");
if (x == "next" && hv < 8) {
document.getElementById(x).style.visibility="hidden";
}
if (x == "previous" && imgno <= 9) {
document.getElementById(x).style.visibility="hidden";
}
}
</script>
Below is the HTML that calls the javascript:
Code:
<div id="previous" onclick="hideShow('previous',hv,imgno)">
<a href="#" class="nav_r" onclick="document.location.href='MY_URL'; return false;">Previous</a>
</div>
<div id="next" onclick="hideShow('next',hv,imgno)">
<a href="#" class="nav_r" onclick="document.location.href='MY_URL'; return false;">Next</a>
</div>
Any help will be greatly appreciated
When I remove the alert("!"); it will no longer hide and show the next/previous buttons as it does with the alert("!"). It does however seems to work OK when I do include the alert("!"), which is a pain as obviously it pops up every time you move to the next page.
javascript Code:
<script type="text/javascript">
function hideShow(x, hv, imgno) {
alert("!");
if (x == "next" && hv < 8) {
document.getElementById(x).style.visibility="hidden";
}
if (x == "previous" && imgno <= 9) {
document.getElementById(x).style.visibility="hidden";
}
}
</script>
Below is the HTML that calls the javascript:
Code:
<div id="previous" onclick="hideShow('previous',hv,imgno)">
<a href="#" class="nav_r" onclick="document.location.href='MY_URL'; return false;">Previous</a>
</div>
<div id="next" onclick="hideShow('next',hv,imgno)">
<a href="#" class="nav_r" onclick="document.location.href='MY_URL'; return false;">Next</a>
</div>
Any help will be greatly appreciated