JS slideshow help

surreal5335

New Member
Messages
28
Reaction score
0
Points
0
I am in the process of creating a slideshow with Javascript. my first image will load but it wont react when changing to the next image or go back.
I put the chgslide commands in two separate usemaps, is this an issue?

One other question I have is how do I put the code into its own scolling box?

Is that simply just a text area tag?

Thanks a lot for the help
 

VPmase

New Member
Messages
914
Reaction score
1
Points
0
I suggest you post your code for the slideshow here so we can see whats wrong.
 

surreal5335

New Member
Messages
28
Reaction score
0
Points
0
sorry about that here it is

Code:
<area shape="rect" coords="66, 426, 168, 474" href="javascript: chgSlide(-1)"/>
</map>

<img src="http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/illustrationsleft.png"  usemap="#illustrationsleft" id="illustrationsleft" hspace="0" vspace="10" align="center"><br>

</td>
<td width="80%">
<!--iframe table--!>



    <title>Image Slideshow</title>

<script language="javascript" type="text/javascript">
<!-- hide script from old browsers

    doll.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/samples/dollsample.png"
    rose.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/rosesample.png"
    teacup.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/teacupsample.png"
    bear.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/bearsample.png"
    sheep.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/sheepsample.png"
    windowshutter.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/windowshuttersample.png"
    hand.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/skeletonhandsample.png"
    pumpkin.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/pumpkinsample.png"
    note.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/notesample.png"
    mail.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/Mailsample.png"
    book.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/Booksample.png"

    mypix = new array("rose.src", "doll.src", "teacup.src", "bear.src", "sheep.src", "windowshutter.src", "hand.src", "pumpkin.src", "note.src", "mail.src", "book.src")
    thispic = 0

    imgCt = mypix.length - 1

    function chgslide(direction) {
        if (document.images) {
            thispic = thispic + direction
            if (thispic > imgCt) {
            thispic = 0
}
        if (thispic < 0) {
            thispic = imgCt
}
    document.mypicture.src=mypix[thispic]
}
}

//end hiding script from old browsers -->

</script>


<p align="center"><img src="http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/samples/dollsample.png" border="1" name="mypicture" width="75%" height="500" alt="slideshow" /></p>
</td>
<td width="10%">

<map name="illustrationsright" id="illustrationsright" align="right">
<area shape="rect" coords="61, 253, 164, 314" href="rates.html"/>
<area shape="rect" coords="61, 420, 164, 488" href="javascript: chgSlide(1)"/>
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
There's a lot of errors with that code. You define 'chgslide' but you use 'chgSlide' (note the capitalized S), you call chgSlide() in that <area> tag before it's defined, you're trying to set the src property of variables which haven't even been defined, you use 'new array()' instead of 'new Array()', and lastly you set the array elements to the string names of those variables you defined and not the values they hold.

So your script should look like this:

Code:
<script language="javascript" type="text/javascript">
<!-- hide script from old browsers
    var doll = new Image();
    var rose = new Image();
    var teacup = new Image();
    var bear = new Image();
    var sheep = new Image();
    var windowshutter = new Image();
    var hand = new Image();
    var pumpkin = new Image();
    var note = new Image();
    var mail = new Image();
    var book = new Image();
    doll.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/samples/dollsample.png"
    rose.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/rosesample.png"
    teacup.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/teacupsample.png"
    bear.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/bearsample.png"
    sheep.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/sheepsample.png"
    windowshutter.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/windowshuttersample.png"
    hand.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/skeletonhandsample.png"
    pumpkin.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/pumpkinsample.png"
    note.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/notesample.png"
    mail.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/Mailsample.png"
    book.src = "http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/Booksample.png"

    var mypix = new Array(rose.src, doll.src, teacup.src, bear.src, sheep.src, windowshutter.src, hand.src, pumpkin.src, note.src, mail.src, book.src)
    var thispic = 0

    var imgCt = mypix.length - 1

    function chgslide(direction) {
        if (document.images) {
        thispic = thispic + direction
        if (thispic > imgCt) {
            thispic = 0
        }
            if (thispic < 0) {
                thispic = imgCt
        }
        document.mypicture.src=mypix[thispic]
    }
    }
//end hiding script from old browsers -->

</script>
And then you should also place the script above all other content, preferably in the <head> section.
 
Last edited:

surreal5335

New Member
Messages
28
Reaction score
0
Points
0
Thanks a lot for the detail of what is wrong and rewriting the script as well. It works perfect!
 
Top