PDA

View Full Version : Two Javascripts On One Page


mkalishoek
09-01-2002, 11:51 AM
:eek: Hey!

I really tried a lot to fix it, but it still doesnt work..
Im not that good with html and javascript cause i started to work with it like a week ago....

I wanted this one on my homepage:
http://javascriptkit.com/script/script2/pslide2.shtml

but i have two different sises of photo's..so i want to have TWO of those on my home page, on the same page, one for the normal sise, and one for the special sised pictures...

but when i put two of them on my page...

and i click the next button of the first one..it goes to the next photo, on the second photoslider!

Can some one help me with this?

And if this is not possible what i want, can i add those "special sised" photo's in one photoslider, but then it doesnt look crappy (streched and resised), but the photo slider gets the format of the photo?

i hope someone knows what i mean, and i hoop you can help me...

mkalishoek...

joh6nn
09-01-2002, 12:32 PM
here you go, all set up to handle two ( or three, or four, etc )

<script language="JavaScript1.1">

/*
Photo Slider II- By Kevin Adams (kadams@kyk.net)
For this script and more
Visit http://www.javascriptkit.com
*/

var photos1=new Array();
var photos2=new Array();
var text1=new Array()
var text2=new Array()
var which1=0;
var which2=0;

//Change the below variables to reference your own images. You may have as many images in the slider as you wish
photos1[0]="http://www.javascriptsolutions.com/imagesOLD/Img002.jpg"
photos1[1]="http://www.javascriptsolutions.com/imagesOLD/Img003.jpg"
photos1[2]="http://www.javascriptsolutions.com/imagesOLD/Img004.jpg"
photos1[3]="http://www.javascriptsolutions.com/imagesOLD/Img005.jpg"
photos1[4]="http://www.javascriptsolutions.com/imagesOLD/ministix4.jpg"
photos1[5]="http://www.javascriptsolutions.com/imagesOLD/ministix5.jpg"
photos1[6]="http://www.javascriptsolutions.com/imagesOLD/ministix6.jpg"

//change coresponding description
text1[0]="Libby watching another dog from the front porch"
text1[1]="A calm moment. EXTREMELY RARE!"
text1[2]="Curious as to what that flash was all about"
text1[3]="Mad at Momma for taking pictures."
text1[4]="Libby striking back!"
text1[5]="They make messes and they lay in them."
text1[6]="Libby catching a frisbee, Ministix following."

//Change the below variables to reference your own images. You may have as many images in the slider as you wish
photos2[0]="http://www.javascriptsolutions.com/imagesOLD/Img002.jpg"
photos2[1]="http://www.javascriptsolutions.com/imagesOLD/Img003.jpg"
photos2[2]="http://www.javascriptsolutions.com/imagesOLD/Img004.jpg"
photos2[3]="http://www.javascriptsolutions.com/imagesOLD/Img005.jpg"
photos2[4]="http://www.javascriptsolutions.com/imagesOLD/ministix4.jpg"
photos2[5]="http://www.javascriptsolutions.com/imagesOLD/ministix5.jpg"
photos2[6]="http://www.javascriptsolutions.com/imagesOLD/ministix6.jpg"

//change coresponding description
text2[0]="Libby watching another dog from the front porch"
text2[1]="A calm moment. EXTREMELY RARE!"
text2[2]="Curious as to what that flash was all about"
text2[3]="Mad at Momma for taking pictures."
text2[4]="Libby striking back!"
text2[5]="They make messes and they lay in them."
text2[6]="Libby catching a frisbee, Ministix following."


window.onload= function() {
document.rotater1.description.value=text1[0];
document.rotater2.description.value=text2[0];
}

function backward(num){
if ( window['which' + num] > 0 ){
window['which' + num]--;
document.images['photoslider'+num].src = window['photos' + num][window['which' + num]];
document['rotater'+num].description.value = window['text' + num][window['which' + num]];
}
}

function forward(num){
if ( window['which'+num] < window['photos'+num].length-1){
window['which' + num]++;
document.images['photoslider'+num].src = window['photos' + num][window['which' + num]];
document['rotater'+num].description.value = window['text' + num][window['which' + num]];}
}

function sover(num){
window['which'+num] = 0;
document.images['photoslider'+num].src = window['photos' + num][window['which' + num]];
document['rotater'+num].description.value = window['text' + num][window['which' + num]];
}

</script>


<table border="0" cellpadding="0">
<caption><strong>Kevin's pet dog</strong></caption>
<tr>
<td width="100%"><img src="http://www.javascriptsolutions.com/imagesOLD/Img002.jpg" width="400" height="264" name="photoslider1"></td>
</tr>
<tr>
<td width="100%"><form method="POST" name="rotater1">
<div align="center"><center><p>

<p><input type=text name="description" style="width:400px" size=50>

<p><input type="button" value="&lt;&lt;Back" name="B2"
onClick="backward(1)"> <input type="button" value="Next&gt;&gt;" name="B1"
onClick="forward(1)"><br>
<a href="#" onClick="sover(1); return false"><small>Start Over</small></a></p>
</center></div>
</form>
</td>
</tr>
</table>



<table border="0" cellpadding="0">
<caption><strong>Kevin's pet dog</strong></caption>
<tr>
<td width="100%"><img src="http://www.javascriptsolutions.com/imagesOLD/Img002.jpg" width="400" height="264" name="photoslider2"></td>
</tr>
<tr>
<td width="100%"><form method="POST" name="rotater2">
<div align="center"><center><p>

<p><input type=text name="description" style="width:400px" size=50>

<p><input type="button" value="&lt;&lt;Back" name="B2"
onClick="backward(2)"> <input type="button" value="Next&gt;&gt;" name="B1"
onClick="forward(2)"><br>
<a href="#" onClick="sover(2); return false"><small>Start Over</small></a></p>
</center></div>
</form>
</td>
</tr>
</table>

<p align="center"><font face="arial" size="-2">This free script provided by</font><br>
<font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript
Kit</a></font></p>

mkalishoek
09-01-2002, 12:41 PM
joh6nn, you are the best...

Know i see what i did wrong...

thank you very much....

mkalishoek
09-01-2002, 04:10 PM
It still doesnt work...

read the "joh6nn it still doesnt work" topic...and you see...