Start & stop slideshow with same button?

This is a discussion on "Start & stop slideshow with same button?" within the JavaScript Forum section. This forum, and the thread "Start & stop slideshow with same button? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Mar 15th, 2007, 21:45
New Member
Join Date: Mar 2007
Location: Toledo, Ohio
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Angry Start & stop slideshow with same button?

Hello to all,

can someone please tell me how to start and stop with the same button in my slide show? My slideshow already runs when I click my "View Show" button, I set up my function so that when I click the "View Show" button, the text on the button changes to "Stop", and the slide show starts. I don't know how to make the slide show stop if I click the button again.
Reply With Quote

  #2 (permalink)  
Old Mar 15th, 2007, 23:07
JacobHaug's Avatar
SuperMember

SuperMember
Join Date: Dec 2005
Location: On Internet
Posts: 4,859
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to JacobHaug Send a message via MSN to JacobHaug
Re: Start & stop slideshow with same button?

What program is this you are referring to? I am very confused!!
Reply With Quote
  #3 (permalink)  
Old Mar 15th, 2007, 23:12
New Member
Join Date: Mar 2007
Location: Toledo, Ohio
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Start & stop slideshow with same button?

I apologize...I am using JavaScript to make a slideshow for my class. Here is the script I am using to run my show:

Code: Select all
var imagenumber = 1;
var totalimages = img_info.length - 1;
function showSlide(direction){
 if (direction == "next"){
  (imagenumber == totalimages) ? imagenumber = totalimages :
 imagenumber++; 
  }else{
  (imagenumber == 0) ? imagenumber = 0 :
 imagenumber--;
 }
 if (direction == "next" && document.slidecontrols.repeater.checked){
  (imagenumber == totalimages) ? imagenumber = 0 :
  imagenumber++;
  }  
 if (document.images){
  document.mainframe.src = img_info[imagenumber].fname;
  document.getElementById('img_title').innerHTML = img_info[imagenumber].title;
  document.getElementById('img_date').innerHTML = img_info[imagenumber].date;
  document.getElementById('img_time').innerHTML = img_info[imagenumber].time;
  document.getElementById('img_camera').innerHTML = img_info[imagenumber].camera;
  document.getElementById('img_descr').innerHTML = img_info[imagenumber].descr;
 }
}
function slideShow(){
 setInterval("showSlide('next')", 7000);
 document.slidecontrols.showbutton.value = "Stop";}
So I have my "View Show" button with an onclick handler to run the slide show, and when I click the button to start the show, the text turns to "Stop" but I cant figure out how to add a function to click the same button to stop the show. Right now, if the show is going, and I click the button again, it just keeps going. And something else I've noticed is that when I have my cycle checkbox checked, it skips some of my slides.

Last edited by karinne; Mar 16th, 2007 at 11:52. Reason: Please use [code]...[/code] tags when displaying code!
Reply With Quote
  #4 (permalink)  
Old Mar 15th, 2007, 23:14
JacobHaug's Avatar
SuperMember

SuperMember
Join Date: Dec 2005
Location: On Internet
Posts: 4,859
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to JacobHaug Send a message via MSN to JacobHaug
Re: Start & stop slideshow with same button?

So this would be best to put it in the JavaScript forum...huh? No worries, I moved it there for ya!!
Reply With Quote
  #5 (permalink)  
Old Mar 15th, 2007, 23:15
New Member
Join Date: Mar 2007
Location: Toledo, Ohio
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Start & stop slideshow with same button?

Duhhh...sorry...I am still learning how to post.
Reply With Quote
  #6 (permalink)  
Old Mar 15th, 2007, 23:34
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Start & stop slideshow with same button?

What triggers the slideshow?
Reply With Quote
  #7 (permalink)  
Old Mar 16th, 2007, 01:53
New Member
Join Date: Mar 2007
Location: Toledo, Ohio
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Start & stop slideshow with same button?

I have a button "View Show" with onclick="slideShow('next')"

here is the slideShow function:

Code: Select all
function slideShow(){
 setInterval("showSlide('next')", 7000);
 document.slidecontrols.showbutton.value = "Stop";}
 
 
And here is the showSlide function:
 
var imagenumber = 1;
var totalimages = img_info.length - 1;
function showSlide(direction){
 if (direction == "next"){
  (imagenumber == totalimages) ? imagenumber = totalimages :
 imagenumber++; 
  }else{
  (imagenumber == 0) ? imagenumber = 0 :
 imagenumber--;
 }
 if (direction == "next" && document.slidecontrols.repeater.checked){
  (imagenumber == totalimages) ? imagenumber = 0 :
  imagenumber++;
  }  
 if (document.images){
  document.mainframe.src = img_info[imagenumber].fname;
  document.getElementById('img_title').innerHTML = img_info[imagenumber].title;
  document.getElementById('img_date').innerHTML = img_info[imagenumber].date;
  document.getElementById('img_time').innerHTML = img_info[imagenumber].time;
  document.getElementById('img_camera').innerHTML = img_info[imagenumber].camera;
  document.getElementById('img_descr').innerHTML = img_info[imagenumber].descr;
 }
}

I don't know if you needed all of that, if not, sorry.

Last edited by karinne; Mar 16th, 2007 at 11:53. Reason: Please use [code]...[/code] tags when displaying code!
Reply With Quote
Reply

Tags
dhtml, function, javascript, slideshow

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Music on/Off (does not stop in IE7) Need Help! Webill JavaScript Forum 2 May 11th, 2008 11:27
How to stop the browser refresh on clicking the webbrowser's refresh button ? camarun20 JavaScript Forum 3 Mar 18th, 2008 23:04
How do I stop it scrolling to the top? marksk Web Page Design 2 Jul 26th, 2007 20:32
Just want simple Background Song (.mp3) and a simple start/stop. BlackReef Flash & Multimedia Forum 4 Jun 28th, 2007 07:04
When a button refuses to behave like a button in Flash autumn_whispers2me Flash & Multimedia Forum 2 May 24th, 2005 22:08


All times are GMT. The time now is 19:17.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43