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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pictures in array 1

Status
Not open for further replies.

maboline

Programmer
Jan 10, 2003
6
DE
Hi,
I am sure this was asked many times before, but I can't seem to find it. (Perhaps due to my English?)
I am populating an array with pics and want to display them in a kind of slidshow afterwards. This is going to be a client side script not server side.
Could you tell me the code for displaying the pics in the array?
Thanks.
mab
 
I think this is a JavaScript issue here. VBScript is used for Server-side scripting, so in your case VBScript won't do the job. Maybe you should re-ask the question in the forum: programmers - Javascript.

Javascript is a powerful client-side scripting language. I've seen slideshows that were made with JavaScript.

Greetings,
Steven
 
Thank you. But I am doing a lot of JavaScript with VBScript... Will search more.
Thanks again.
mab
 
Contrary to popular belief, VBScript is not "used for server-side scripting." VBScript has many uses, and client-side scripting is one of them. Of course it is very true that using client VBScript can limit your web page's audience drastically. That's the best reason to stick with JavaScript on the client: public web pages.

I'm not exactly sure what you mean by wanting to populate an array with pictures. Since the <img> element loads pictures via its
Code:
src
attribute anyway, maybe you mean storing an array of URLs to the actual image files?

Then again, for smooth operation it is common for people to &quot;preload&quot; images in JavaScript. The JavaScript syntax:
Code:
v = new Image()
... isn't such a wonder as many think it is. The advantage is that it does offer a browser-independent way to do something offered by Internet Explorer through the DOM already though.

In any case, here is a quick and dirty conversion of a JavaScript slideshow page I found into VBScript for IE. It both preloads the images and stores URL strings in an array as I described. As noted in the comments, I got it from CodeLifter.com:
Code:
<html>
<head>
<style>
 .Caption {font-family: Arial;
           font-weight: bold;
           color:      #123456}
</style>
<script language=VBScript>
  'Adapted to VBScript from:
  ' (C) 2002 [URL unfurl="true"]www.CodeLifter.com[/URL]
  ' [URL unfurl="true"]http://www.codelifter.com[/URL]
  ' Free for all users, but leave in this header.
  Option Explicit

  Const SlideShowSpeed = 3000
  Const CrossFadeDuration = 3
  Dim Picture
  Dim Caption
  Dim preLoad()

  Picture = Array(&quot;Image001.jpg&quot;, &quot;Image002.jpg&quot;, &quot;Image003.jpg&quot;)
  Caption = Array(&quot;This is the first caption.&quot;, _
                  &quot;This is the second caption.&quot;, _
                  &quot;This is the third caption.&quot;)
  Dim iss
  Dim jss
  jss = 0

  ReDim preLoad(UBound(Picture))
  For iss = 0 to UBound(Picture)
    Set preLoad(iss) = document.createElement(&quot;IMG&quot;)
    preLoad(iss).src = Picture(iss)
  Next

  Sub window_onload()
    PictureBox.style.filter = &quot;blendTrans(duration=2)&quot;
    PictureBox.style.filter = &quot;blendTrans(duration=CrossFadeDuration)&quot;
    PictureBox.filters.blendTrans.Apply
    PictureBox.src = preLoad(jss).src
    CaptionBox.innerText = Caption(jss)
    PictureBox.filters.blendTrans.Play
    jss = jss + 1
    If jss > UBound(Picture) Then jss = 0
    setTimeout &quot;window_onload&quot;, SlideShowSpeed, &quot;VBScript&quot;
  End Sub
</script>
</head>
<body bgcolor=#000000>
  <table border=0 cellpadding=0 cellspacing=0>
    <tr>
      <td width=350 height=280>
        <img src=Image001.jpg id=PictureBox width=350 height=280>
      </td>
    </tr>
    <tr>
      <td id=CaptionBox class=Caption align=center bgcolor=#fedcba>
        This is the default caption.
      </td>
    </tr>
  </table>
</body>
</html>
Is this close to what you were after?

See CodeLifter.com for a JavaScript version with comments left in to tell what is going on here.
 
Thank you Dilettante. That was exactly what I was looking for.
The problem with VBScript not interpreted by all browsers is not an issue, since I am mostly writing scripts for Outlook Express stationary *g*
Thank you again.
mab
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top