Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 10-03-2009, 10:13 PM Array help needed
Novice Talker

Posts: 11
Trades: 0
I'm trying to implement a script that provides two buttons with which one can click forward and backward to view a bunch of images. The image starts with a1.jpg and then as you click forward, it changes to a2.jpg, etc. For some reason, the first 3 images load fine. When I add a4.jpg to the array, it doesn't work -- I can click to the third image but not the fourth. Can anyone help me? I'm stumped! Thank you!



<img name="myPicture" src="a1.jpg">

<script language="JavaScript">
<!--

var myPix = new Array("a1.jpg","a2.jpg","a3.jpg","a4.jpg")
var thisPic = 0

function doPrevious() {
if (document.images && thisPic > 0) {
thisPic--
document.myPicture.src=myPix[thisPic]
}
}

function doNext() {
if (document.images && thisPic < 2) {
thisPic++
document.myPicture.src=myPix[thisPic]
}
}
// -->
</script>
</p>
<p><a href="javascript:doPrevious()"><img src="backward.jpg" border="none"></a><a href="javascript:doNext()"><img src="forward.jpg" border="none"></a></p>
jodybethw is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-05-2009, 12:27 AM Re: Array help needed
Junior Talker

Posts: 1
Trades: 0
Great little topic.
And Nice work--thank you for sharing- for me this makes perfect sense though.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
takilate is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Array help needed
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.35431 seconds with 12 queries