I am new to using Javascript so don't really know the terms for things.
I have two navigation cursors which then cycle through the array.
What I want is to be able to display the image number and the total number of images for each image, and obviously change it as the image changes. i.e. this is image 1 of 10, which changes with the image
I have done this as a seperate function, though i don't know if it works like this, or if there is a more simple way of printing the index order of the array.
the script appears below
Expand|Select|Wrap|Line Numbers
- <SCRIPT LANGUAGE="JavaScript">
- <!--
- // test the browser to make sure it's ok
- var browserName = navigator.appName;
- var browserVer = parseInt(navigator.appVersion);
- var browserOK = (((browserName == "Netscape") && (browserVer >= 3)) ||
- ((browserName == "Microsoft Internet Explorer") && (browserVer >= 4)));
- // URLs of images in slide show
- var slideURL = <?php echo ($img_list); ?>
- // delay between slides (in milliseconds)
- var slideDelay = 100000;
- // Index of the current slide
- var curSlide = -1;
- // timeout id for the current setTimeout command
- var curTimeout;
- var picTotal = <?php echo ($i-2); ?>;
- var curPic = 1;
- function showSlide() {
- if (browserOK) {
- // alert(slideURL.length);
- curSlide = ((curSlide + 1) % slideURL.length);
- // alert(curSlide);
- document.images["slideImg"].src = slideURL[curSlide];
- curTimeout = setTimeout("showSlide()", slideDelay);
- } else {
- // show an error message for older browsers
- alert("This page requires Netscape 3.0+ or IE 4.0+");
- }
- }
- function increment_picNum()
- {
- if (curPic < picTotal)
- {
- curPic= (curPic+1);
- }
- else
- {
- curPic=1;
- }
- var curPic=document.getElementById("pic_number");
- }
- function decrement_picNum()
- {
- if (curPic>1)
- {
- curPic=(curPic-1);
- }
- else
- {
- curPic=picTotal;
- }
- var curPic=document.getElementById("pic_number");
- }
- //function of one cursor
- function goNext() {
- if (browserOK){
- clearTimeout(curTimeout);
- showSlide();
- increment_picNum();
- }
- }
- //function of the other
- function goPrev() {
- if (browserOK) {
- clearTimeout(curTimeout);
- curSlide = (((curSlide - 2) + slideURL.length) % slideURL.length);
- showSlide();
- decrement_picNum();
- }
- }
- // -->
- </SCRIPT>
The filenames are indexed as above.
I've been scratching my head for hours on this one, please help!