![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Jul 2008
Posts: 18
OS: Mac OS X 10.5.4
|
[SOLVED] Javascript newbie <<<<
Hey there. I am doing a website for a client and they're looking for a simple slideshow... the clickable kind. I'm having trouble with the Javascript. All I need is the pictures to rotate within one cell on one page when clicked upon. Anyone have a script lying around they can lend me to reverse engineer or a website that goes over it (besides javascriptkit, there's some compatibility issues there some how)?
Thanks Jim |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,887
OS: Vista, various linux distros
|
Re: Javascript newbie <<<<
Hey, it would be useful if you could post your code (e.g. the code which you've tried to write)... anyway, i can mock up a basic script:
Code:
//set up an array to hold the url/relative url of the images(src)
var images = new Array();
slideshowImages[0] = "image1.jpg";
slideshowImages[1] = "image2.jpg";
slideshowImages[2] = "image3.jpg";
//a counter to hold the current image number(index)
var currentImage = 0;
//a function to swap the image
function swap(id, image){
//set the src of the image as the new image url
document.getElementById(id).src = image;
}
//a function to rotate/cycle between all images
function cycleImages(id){
//increment the current image's index
currentImage++;
//if it's the maximum number of images then make it zero
//note: the index starts at zero so this is correct (ask for more help if necessary)
if(currentImage == slideshowImages.length){
currentImage = 0;
}
swap(id, slideshowImages[currentImage]);
}
//Implementation:
//you need the id of the image (<img id="blah"... for the sakes of this example)
//to cycle once run:
cycleImages("blah");
//to cycle constantly run:
var slideshowInterval = setInterval("cycleImages('blah');", 1000);
//1000 being 1000 milliseconds (one second)
Then of course if you wan't it to just be clickable then set up an item with the onClick event handler of "cycleImages('blah');"... If you need this extending or if you need more help then post back... Cheers, Jamey |
|
|
|
|
|
#3 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,887
OS: Vista, various linux distros
|
Re: Javascript newbie <<<<
p.s. if you do have code with a more specific nature (e.g. you have already set up the webpage and you need to just make things work).. then feel free to post it and we can take a look at it.
Cheers, Jamey |
|
|
|
![]() |
| Thread Tools | |
|
|