•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 427,025 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,517 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1976 | Replies: 2
![]() |
•
•
Join Date: Jul 2006
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
I am new to this whole Javascript world being primarily a comedy writer. I pasted Photoslider II into my website and it worked fine but when I add additional Photosliders (same code) everything gets screwed up. I know this is due to duplicate variables but I don't know how to change them and what do I change them to? I'll paste the code below. Also how hard would it be to tweek the code so that when I click on a thumbnail pic in the slideshow a pop up window with a larger version of the same pic would appear in a separate window? For now I would be happy just to use three Photosliders on my index page. I've been trying to find this answer for two weeks now. Thanks for the help and your time.
Tom ComedyFarm@yahoo.com
<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="photoslider"></td>
</tr>
<tr>
<td width="100%"><form method="POST" name="rotater">
<div align="center"><center><p>
<script language="JavaScript1.1">
/*
Photo Slider II- By Kevin Adams (kadams70@hotmail.com)
For this script and more
Visit http://www.javascriptkit.com
*/
var photos=new Array()
var text=new Array()
var which=0
var what=0
//Change the below variables to reference your own images. You may have as many images in the slider as you wish
photos[0]="http://www.javascriptsolutions.com/imagesOLD/Img002.jpg"
photos[1]="http://www.javascriptsolutions.com/imagesOLD/Img003.jpg"
photos[2]="http://www.javascriptsolutions.com/imagesOLD/Img004.jpg"
photos[3]="http://www.javascriptsolutions.com/imagesOLD/Img005.jpg"
photos[4]="http://www.javascriptsolutions.com/i.../ministix4.jpg"
photos[5]="http://www.javascriptsolutions.com/i.../ministix5.jpg"
photos[6]="http://www.javascriptsolutions.com/i.../ministix6.jpg"
//change coresponding description
text[0]="Libby watching another dog from the front porch"
text[1]="A calm moment. EXTREMELY RARE!"
text[2]="Curious as to what that flash was all about"
text[3]="Mad at Momma for taking pictures."
text[4]="Libby striking back!"
text[5]="They make messes and they lay in them."
text[6]="Libby catching a frisbee, Ministix following."
window.onload=new Function("document.rotater.description.value=text[0]")
function backward(){
if (which>0){
window.status=''
which--
document.images.photoslider.src=photos[which];
what--
document.rotater.description.value=text[what];
}
}
function forward(){
if (which<photos.length-1){
which++
document.images.photoslider.src=photos[which]
what++
document.rotater.description.value=text[what];
}
else window.status='End of gallery'
}
function type()
{
alert("This textbox will only display default comments")
}
</script>
<p><input type=text name="description" style="width:400px" size=50>
<p><input type="button" value="<<Back" name="B2"
onClick="backward()"> <input type="button" value="Next>>" name="B1"
onClick="forward()"><br>
<a href="#" onClick="which=1;what=1;backward();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="<A href="http://javascriptkit.com">JavaScript">http://javascriptkit.com">JavaScript
Kit</a></font></p>
Tom ComedyFarm@yahoo.com
<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="photoslider"></td>
</tr>
<tr>
<td width="100%"><form method="POST" name="rotater">
<div align="center"><center><p>
<script language="JavaScript1.1">
/*
Photo Slider II- By Kevin Adams (kadams70@hotmail.com)
For this script and more
Visit http://www.javascriptkit.com
*/
var photos=new Array()
var text=new Array()
var which=0
var what=0
//Change the below variables to reference your own images. You may have as many images in the slider as you wish
photos[0]="http://www.javascriptsolutions.com/imagesOLD/Img002.jpg"
photos[1]="http://www.javascriptsolutions.com/imagesOLD/Img003.jpg"
photos[2]="http://www.javascriptsolutions.com/imagesOLD/Img004.jpg"
photos[3]="http://www.javascriptsolutions.com/imagesOLD/Img005.jpg"
photos[4]="http://www.javascriptsolutions.com/i.../ministix4.jpg"
photos[5]="http://www.javascriptsolutions.com/i.../ministix5.jpg"
photos[6]="http://www.javascriptsolutions.com/i.../ministix6.jpg"
//change coresponding description
text[0]="Libby watching another dog from the front porch"
text[1]="A calm moment. EXTREMELY RARE!"
text[2]="Curious as to what that flash was all about"
text[3]="Mad at Momma for taking pictures."
text[4]="Libby striking back!"
text[5]="They make messes and they lay in them."
text[6]="Libby catching a frisbee, Ministix following."
window.onload=new Function("document.rotater.description.value=text[0]")
function backward(){
if (which>0){
window.status=''
which--
document.images.photoslider.src=photos[which];
what--
document.rotater.description.value=text[what];
}
}
function forward(){
if (which<photos.length-1){
which++
document.images.photoslider.src=photos[which]
what++
document.rotater.description.value=text[what];
}
else window.status='End of gallery'
}
function type()
{
alert("This textbox will only display default comments")
}
</script>
<p><input type=text name="description" style="width:400px" size=50>
<p><input type="button" value="<<Back" name="B2"
onClick="backward()"> <input type="button" value="Next>>" name="B1"
onClick="forward()"><br>
<a href="#" onClick="which=1;what=1;backward();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="<A href="http://javascriptkit.com">JavaScript">http://javascriptkit.com">JavaScript
Kit</a></font></p>
My initial instinct is to suggest renumbering your array subscripts in the second photo slider. (i.e. change photos[0] to photos[7], etc)
You could also try changing the variable names in the second script from photo and text to photo2 and text2.
I would have to see the entire code and html to make any suggestions beyond that.
You could also try changing the variable names in the second script from photo and text to photo2 and text2.
I would have to see the entire code and html to make any suggestions beyond that.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- How to call a PHP function from Javascript and return the results back into Javascrip (PHP)
- I have a link wich opens a the second page with links wich call a javascript functio (JavaScript / DHTML / AJAX)
- problem in javascript coding in asp page (ASP)
- Help with .js JAVASCRIPT file!!!!!?!!?!? (JavaScript / DHTML / AJAX)
- Page Cannot Be Displayed & javascript:doNetDetect() Errors (Viruses, Spyware and other Nasties)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: How to launch pop-up windows....
- Next Thread: Redirecting a browser with Javascript....


Linear Mode