Link to home
Start Free TrialLog in
Avatar of webdork
webdork

asked on

Javascript loop

I'm trying to preload a variable number of images. I can do most of what I want in asp but I'm not good with js.  I'd like to use only js in the load command but will consider using both vbscript and js. The snippet below is what i want but it's not rendering.

****************CODE**************

'Determine the number of images
picnumof = ((Recordset1.Fields.Item("Pictures - Number of").Value) -1)
'DEBUG TO BE REMOVED
'response.write picnumof


<%
for i=1 to picnumof
imageload = imageload + "'http://vxxxxxxxxx.maximumasp.com/ress/img/40047429_0" & i &".jpg', "
next
%>

<body onLoad="MM_preloadImages('<%=imageload%>')">
Avatar of weddell
weddell

Using a mix of client-side javascript and server-side vbScript might be easier.


<%
'Determine the number of images
picnumof = ((Recordset1.Fields.Item("Pictures - Number of").Value) -1)
'DEBUG TO BE REMOVED
'response.write picnumof
%>

<script language="JavaScript"><!--

    for(var i=0; i < <%=picnumof%>; i++) {
           imageLoad = imageLoad + '/ress/img/40047429_0' + i + '.jpg';
    }

//--></script>

<body onload="MM_preloadImages(imageLoad)">
ASKER CERTIFIED SOLUTION
Avatar of pratap_r
pratap_r
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of webdork

ASKER

Hi Thanks all for your contribution. I'm out of town for Tgiving and away from the PC ball and chain. Back to work on Mon and will test latest suggestions and respond then. (No time for good grammer).