Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript Image Variable

Status
Not open for further replies.

chadsden

Technical User
Oct 21, 2000
4
US
I have a Slide show which consists of an HTML document and an external javascript file. The slide show is at "
Each week, I feature different slides. Currently, I update the external file with the new files and then update the html document with the beginning slide.

What I want to do is get rid of having to change the beginning slide in the HTML each week. Can I just add a variable to my external file and call for it in my HTML file? Could you help me with the proper script?

The external file is as follows:

myPix = new Array("
adURL = new Array("469882367","469882686")
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]

}

}

function newLocation() {

document.location.href = &quot; + adURL[thisPic]

}

The HTML file text is as follows:
<td Background=&quot; width='298' height='260'><A HREF=&quot;javascript:newLocation()&quot;><CENTER>
<!-- ENTER STARTING GALLERY PICTURE -->
<img src=&quot; NAME = &quot;myPicture&quot; width=&quot;170&quot; ALT=&quot;Click to View Auction&quot;></CENTER></td>
<td width='298'><font face='Times New Roman' color=#000000 size=4><B><CENTER>
<A HREF=&quot;javascript:chgSlide(-1)&quot;><< Previous</A>
<A HREF=&quot;javascript:chgSlide(1)&quot;>Next >></A> </CENTER></B></font></td>
Thanx
Cliff [sig][/sig]
 
Without changing it too much couldn't you just do this to the html page...
Code:
<script>
document.write('<img src=&quot;'+ myPix[0] +'&quot; NAME = &quot;myPicture&quot; width=&quot;200&quot; ALT=&quot;Click to View Auction&quot;>')</script>

Later,
[sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
Hi Rob,
Thanx for the reply. By the time I got your answer, I had already done what you recommended and it worked in Internet Explorer, But not in Netscape 3.
If you don't have netscape, heres what happens: The first picture loads ('myPix[0]') and script appears below the picture which repeats the 'document.write' statement with 2 little boxes in front of the statement.

The URL for the gallery is &quot; Here's the link. <a href=&quot; Here! <a/>

If you look at the source in the HTML file, I have revised the prev & next statements from my original posting. They do not show up in Netscape. Challenge #2, I guess.

Any suggestions? I'm sort of lost!
Thanx in advance
Cliff [sig][/sig]
 
Does it work in NN4? If so, you may want to forget about NN3. I believe that the installed base of NN3/IE3 is about 1%. If you still want to pursue the problem I will help as much as I can.

Later, [sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
Hi Rob,
Thanx for the reply. I will try to get a copy of NS 4 installed. I'll let you know what happens.
Thanx again,
Cliff [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top