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

Using a Recordset for "Preload Images" Javascript behavior

Status
Not open for further replies.

kalamp

Programmer
Aug 7, 2003
17
0
0
US
I have hit a wall in a script I'm building for a web site. I'm attempting to use a recordset in a javascript "Preload Images" script. Here's the code I'm using:

<body onLoad=&quot;MM_preloadImages(
<%
While ((Repeat2__numRows <> 0) AND (NOT rsProdFinishPicsPreload.EOF))
%>
'<%=(rsProdFinishPicsPreload.Fields.Item(&quot;attrdtPic&quot;).Value)%>'
<%
If (rsProdFinishPicsPreload_last) Then%> <% Else %>,<% End If
%>
<%
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
rsProdFinishPicsPreload.MoveNext()
Wend
%>
)&quot;>


This is what is being returned from the server:

<body onLoad=&quot;MM_preloadImages('Assets/PdFantasy/Rose FairyR.jpg','Assets/PdFantasy/Rose FairyP.jpg',)&quot;>

The last &quot;,&quot; is not suppose to be there. As you can see in the code above I tried eliminating the &quot;,&quot; with this:
<%
If (rsProdFinishPicsPreload_last) Then%> <% Else %>,<% End If %>


I'm sure the fix is simple but I've been banging away at this for so long that my mind is numb.

I would greatly appreciate any help on this one.
 
the format:
onLoad=&quot;MM_preloadImages('/images/_1.jpg','/images/_2.jpg')&quot;
ok so how about u use the condition of
&quot;IF rs.EOF then &quot;

> need more info?
:: don't click HERE ::
 
rs.EOF for the IF/THEN won't work in this because I have it inside a WHILE/WEND loop that stops once rs.EOF is reached. I do appreciate your help though.

After walking away from this thing for an hour I came back and figured out the fix in less than two minutes.... Funny how that works sometimes.

All I did was add a blank set of brackets right after the WHILE/WEND loop ends. Works like a charm!

Here's the following fixed code if anyone would like to use it:

Code:
<body onLoad=&quot;MM_preloadImages(
<% 
While ((Repeat2__numRows <> 0) AND (NOT rsProdFinishPicsPreload.EOF)) 
%>
'<%=(rsProdFinishPicsPreload.Fields.Item(&quot;attrdtPic&quot;).Value)%>',
<% 
  Repeat2__index=Repeat2__index+1
  Repeat2__numRows=Repeat2__numRows-1
  rsProdFinishPicsPreload.MoveNext()
Wend%>
'')&quot;>

Once again, thanks for the help.
 
oops never looked at the &quot;WHILE&quot;
nice job!

> need more info?
:: don't click HERE ::
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top