473,499 Members | 1,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JavaScript Picture slider

4 New Member
Hi,

Im not a Java programmer, I do a PHP programs, but now I must implement a Java script for a poicture slideshow.

With this script I can change pictures from examlpe 1 to 10.

But I must to do that i have a 4 pictures in a row and each picture will change 3 pictures => 4 x 3 picture for change.

this code swap the pictures:
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2. <!--
  3. function MM_findObj(n, d) { //v4.0
  4.   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  5.     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  6.   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  7.   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  8.   if(!x && document.getElementById) x=document.getElementById(n); return x;
  9. }
  10.  
  11. function MM_swapImage() { //v3.0
  12.   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  13.    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  14. }
  15. //-->
  16. </script>
This call the pictures (I think):
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/javascript">
  2. <!--
  3. <!--
  4. gSlideshowInterval = 3;
  5. gNumberOfImages = 3;
  6.  
  7. gImages = new Array(gNumberOfImages);
  8. gImages[0] = "up_main_photo/main_resized_photo_1.jpg";
  9. gImages[1] = "up_main_photo/main_resized_photo_2.jpg";
  10. gImages[2] = "up_main_photo/main_resized_photo_3.jpg";
  11. gImages[3] = "up_main_photo/main_resized_photo_4.jpg";
  12.  
  13.  
  14. function canManipulateImages() {
  15.     if (document.images)
  16.         return true;
  17.     else
  18.         return false;
  19. }
  20. function loadSlide(imageURL) {
  21.     if (gImageCapableBrowser) {
  22.  
  23.         document.slide.src = imageURL;
  24.         return false;
  25.     }
  26.     else {
  27.         return true;
  28.     }
  29. }
  30. function nextSlide() {
  31.     gCurrentImage = (gCurrentImage + 1) % gNumberOfImages;
  32.     loadSlide(gImages[gCurrentImage]);
  33. }
  34. gImageCapableBrowser = canManipulateImages();
  35. gCurrentImage = 0;
  36. setInterval("nextSlide()",gSlideshowInterval * 1000);
  37. // -->
  38.  
  39. function MM_preloadImages() { //v3.0
  40.   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  41.     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  42.     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  43. }
  44. //-->
  45. </script>
than I must preload the images in HTML body:
Expand|Select|Wrap|Line Numbers
  1. <body class="MAIN_FRAME_BODY" onLoad="MM_preloadImages('up_main_photo/main_resized_photo_1.jpg, up_main_photo/main_resized_photo_2.jpg,up_main_photo/main_resized_photo_3.jpg, up_main_photo/main_resized_photo_3.jpg)">
and at last - begin the slideshow:
Expand|Select|Wrap|Line Numbers
  1. <img src="up_main_photo/main_resized_photo_1.jpg" alt="" name="slide">
thanx!
Jun 5 '07 #1
6 2141
acoder
16,027 Recognized Expert Moderator MVP
webmaster, welcome to TSDN!

Can you explain the following in a little more detail please?
But I must to do that i have a 4 pictures in a row and each picture will change 3 pictures => 4 x 3 picture for change.
Jun 5 '07 #2
webmaster1
4 New Member
webmaster, welcome to TSDN!

Can you explain the following in a little more detail please?
go to page:

http://www.internetlabor.net/geneza

on main page You can see 4 pictures.

I want to every 4 pictures chage in itself 3 different pictures
Jun 5 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
Ok, I got you.

Add the rest of the images to the gImages array and update gNumberOfImages to 12.

Then you just need to change nextSlide to, e.g. or something similar (perhaps you can think of something similar):
Expand|Select|Wrap|Line Numbers
  1. function nextSlide() {
  2.     gCurrentImage = (gCurrentImage + 1) % 3;
  3.     for (i = 0; i <= 3; i++) loadSlide(gImages[gCurrentImage*i+(gCurrentImage-1)*3]);
  4. }
Jun 5 '07 #4
webmaster1
4 New Member
Ok, I got you.

Add the rest of the images to the gImages array and update gNumberOfImages to 12.

Then you just need to change nextSlide to, e.g. or something similar (perhaps you can think of something similar):
Expand|Select|Wrap|Line Numbers
  1. function nextSlide() {
  2.     gCurrentImage = (gCurrentImage + 1) % 3;
  3.     for (i = 0; i <= 3; i++) loadSlide(gImages[gCurrentImage*i+(gCurrentImage-1)*3]);
  4. }
///////////////////////////
OK,

Ive made the changes, than (oh, maybe Im tired - or too beginner in Java) - but what with slides - mean pictures?

The changes is a next:

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/javascript">
  2. <!--
  3. <!--
  4. gSlideshowInterval = 3;
  5. gNumberOfImages = 12;
  6.  
  7. gImages = new Array(gNumberOfImages);
  8. gImages[0] = "up_main_photo/main_resized_photo_1.jpg";
  9. gImages[1] = "up_main_photo/main_resized_photo_2.jpg";
  10. gImages[2] = "up_main_photo/main_resized_photo_3.jpg";
  11. gImages[3] = "up_main_photo/main_resized_photo_4.jpg";
  12. gImages[4] = "up_main_photo/main_resized_photo_5.jpg";
  13. gImages[5] = "up_main_photo/main_resized_photo_6.jpg";
  14. gImages[6] = "up_main_photo/main_resized_photo_7.jpg";
  15. gImages[7] = "up_main_photo/main_resized_photo_8.jpg";
  16. gImages[8] = "up_main_photo/main_resized_photo_9.jpg";
  17. gImages[9] = "up_main_photo/main_resized_photo_10.jpg";
  18. gImages[10] = "up_main_photo/main_resized_photo_11.jpg";
  19. gImages[11] = "up_main_photo/main_resized_photo_12.jpg";
  20.  
  21.  
  22. function canManipulateImages() {
  23.     if (document.images)
  24.         return true;
  25.     else
  26.         return false;
  27. }
  28. function loadSlide(imageURL) {
  29.     if (gImageCapableBrowser) {
  30.  
  31.         document.slide.src = imageURL;
  32.         return false;
  33.     }
  34.     else {
  35.         return true;
  36.     }
  37. }
  38. function nextSlide() {
  39.     gCurrentImage = (gCurrentImage + 1) % 3;
  40.     for (i = 0; i <= 3; i++) loadSlide(gImages[gCurrentImage*i+(gCurrentImage-1)*3]);
  41. }
  42. gImageCapableBrowser = canManipulateImages();
  43. gCurrentImage = 0;
  44. setInterval("nextSlide()",gSlideshowInterval * 1000);
  45.  
  46. // -->
  47.  
  48. function MM_preloadImages() { //v3.0
  49.   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  50.     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  51.     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  52. }
  53. //-->
  54. </script>
Expand|Select|Wrap|Line Numbers
  1. <body class="MAIN_FRAME_BODY" onLoad="MM_preloadImages('up_main_photo/main_resized_photo_1.jpg, up_main_photo/main_resized_photo_2.jpg,up_main_photo/main_resized_photo_3.jpg, up_main_photo/main_resized_photo_3.jpg,up_main_photo/main_resized_photo_4.jpg, up_main_photo/main_resized_photo_5.jpg,up_main_photo/main_resized_photo_6.jpg, up_main_photo/main_resized_photo_7.jpg,up_main_photo/main_resized_photo_8.jpg, up_main_photo/main_resized_photo_9.jpg,up_main_photo/main_resized_photo_10.jpg, up_main_photo/main_resized_photo_11.jpg,up_main_photo/main_resized_photo_12.jpg)">
Expand|Select|Wrap|Line Numbers
  1. <img src="up_main_photo/main_resized_photo_1.jpg" alt="" name="slide">
  2. <img src="up_main_photo/main_resized_photo_4.jpg" alt="" name="slide">
  3. <img src="up_main_photo/main_resized_photo_7.jpg" alt="" name="slide">
  4. <img src="up_main_photo/main_resized_photo_10.jpg" alt="" name="slide">
  5.  
Jun 5 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
Ok, you're displaying 1,4,7 and 10, so you're going to have to change the code for nextSlide so that it displays 2,5,8 and 11 (remember array indices are one less) on the next go.
Jun 6 '07 #6
webmaster1
4 New Member
Ok, you're displaying 1,4,7 and 10, so you're going to have to change the code for nextSlide so that it displays 2,5,8 and 11 (remember array indices are one less) on the next go.

Dear Acoder - thank You for help for now - Ive must sit and think abot this code - I belive is simple as the other programs - but I dont have a time now I must finish site very soon - so I can return for this "problem" in near future. For now Ive made the alternative resolution:

Ive made a 3 separately files, in each are a 3 files for a sliding, than I inserted this files into "main" file as iframe, and its work.

visit the: www.geneza.co.yu/index_main.php
Jun 8 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
4465
by: Saqib Ali | last post by:
I have created a slider using Javascript and html tables that generally works very well. As you move the "knob" to the right, a numeric value in an adjactent <INPUT type="text"> tag increases....
2
1964
by: bigoxygen | last post by:
Hi. Anybody know where I could find a nice JavaScript/DHTML slider? I am going to give my users 300 points, and the maximum values on the 3 sliders must add up to 300... Would this be hard to...
1
2262
by: Israel | last post by:
The problem: I want to know, definitively when a slider loses focus after a user has started sliding and hasn't released the mouse yet. It appears that this is captured with the WM_ACTIVATEAPP...
4
1591
by: kiran | last post by:
hi, iam facing a problem in javascript. iam using a slider in program. i requires a js file which i have included. iam passing a parameter through this statement s.function(v). the function is in...
6
8632
by: James007 | last post by:
Hi everyone, I am developing a web page for an embedded application. I created a text box for entering a value (only 1 byte long). The onchange event triggers correctly when I enter the value...
8
1600
by: pitstop10 | last post by:
I use cutehtml as these are my starting days with Javascripts. The script generated by CuteHTML works in IE and Opera. It does not however work in Mozilla. its a slideshow of images. The problem with...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7386
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.