Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 12th, 2005, 11:49 AM
Authorized User
Join Date: Jan 2005
Location: , , .
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Default Populate a popup from an array

Hey all...

I am trying to use a combination of asp and javascript to create a photo album

My asp works great but I am having trouble with the Javascript..

here is the code...notice that I pass the info to a javascript array...cont below...

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set fldr = FSO.GetFolder( Server.MapPath("/folder") )

Dim names
ReDim names( fldr.Files.Count ) ' will be overkill

count = -1
For Each fl In fldr.Files
fname = fl.Name
' get the extension
ext = LCase( Mid( fname, 1 + InStrRev( fname, "." ) ) )
If ext = "jpg" OR ext = "jpeg" OR ext = "gif" Then
count = count + 1
names(count) = fname
<A HREF="#" onClick="show(<%=count%>); return false;">
<IMG SRC="/folder/<%=fname%>" width=150>
... other html ...
End If

ReDim Preserve names(count) ' chop array to needed size
<SCRIPT Language="JavaScript">
var imgNames = new Array('<%=Join(names,"','")%>');

I can view source and know that the array is being populated...can post an example if necessary...

but how do I pass this info to the popup so that it can display the correct picture from the array in the popup and then add a "back" and "next" buttons to scroll up or down in the array and show the appropriate pictures accordingly

I'd pull my hair out but I don't have any...

Reply With Quote
  #2 (permalink)  
Old August 13th, 2005, 04:31 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

Your show function would look like this:
function show(ImageIndex)
  var sName = imgName[ImageIndex];
  var sHTML = "<html><body><img src=\" + sName + "\"></body></html>";
  var oWin = window.open("");
  var oDoc = oWin.document;
For next and previous you will have to have code in the new window to link to the relevant image. It would be easier if your show function took the name of the image, instead of writing the count put the image source, and have a second parameter for whetehr a new window is needed or not. This way it can be re-used for both windows.


Joe (Microsoft MVP - XML)
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
Populate Array with SQL query string nicoleh Classic ASP Databases 3 July 6th, 2005 02:55 PM
error when sorting an Array of Array nancy VBScript 2 February 17th, 2005 12:57 PM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM

All times are GMT -4. The time now is 11:43 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.