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:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* 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
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read

Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
Thread Tools
Old 07-14-2008, 02:43 PM   #1 (permalink)
Registered User
 
Join Date: Jul 2008
Posts: 6
OS: Mac OS X 10.5.4


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
tacmed1 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 07-15-2008, 08:07 AM   #2 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Northampton, UK
Posts: 935
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)


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)
This would work(havent checked it so if it doesn't then post to tell me) as a forward cycling slideshow, it can be adapted easily to cycle backwards aswell as forwards...
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
__________________

Help fight cancer. < I just started =]
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 07-15-2008, 08:09 AM   #3 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Northampton, UK
Posts: 935
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)


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
__________________

Help fight cancer. < I just started =]
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 07-17-2008, 07:20 AM   #4 (permalink)
Registered User
 
Join Date: Jul 2008
Posts: 6
OS: Mac OS X 10.5.4


Re: Javascript newbie <<<<

Thanks Jamey. After getting to know it, it worked! Let's knock on wood.
tacmed1 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Old 07-17-2008, 08:09 AM   #5 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Northampton, UK
Posts: 935
OS: Win Vista Home Premium & Ubuntu Hardy(8.04)


Re: Javascript newbie <<<<

haha kk, glad it worked.

Cheers,
Jamey
__________________

Help fight cancer. < I just started =]
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Bookmark on Thread SoupReddit!
Reply With Quote
Reply


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

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



All times are GMT -7. The time now is 06:13 AM.



Copyright 2001 - 2008, Tech Support Forum

Search Engine Friendly URLs by vBSEO

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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82