Click to See Complete Forum and Search --> : dynamically moving through images


peelmaster
11-08-2003, 02:31 PM
I'm trying to simply move through a series of images dynamically. The code basically works when I test it locally, but when I upload the file and test it using my browser, I get the lovely error message "Operation is not allowed when the object is closed." The other problem that I am having is that when the user gets to the End of File and clicks next, there seems to be a blank record in between the EOF and BOF. Any help would be appreciated.

Here is the code:

<HTML>
<HEAD>
<OBJECT ID ="teampics" CLASSID ="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM NAME = "DataURL" VALUE = "teampics.txt">
<PARAM NAME = "UseHeader" VALUE = "True">
</OBJECT>

<SCRIPT LANGUAGE="JavaScript">

<!--
recordSet = teampics.recordset;

function move( whereTo ) {
switch( whereTo ) {

case "first":

recordSet.MoveFirst();
break;

case "previous":

if ( recordSet.BOF )
recordSet.MoveLast();
else
recordSet.MovePrevious();
break;

case "next":

if ( recordSet.EOF )
recordSet.MoveFirst();
else
recordSet.MoveNext();
break;

case "last":
recordSet.MoveLast();
break;
}
}
// --!>
</SCRIPT>
</HEAD>
<BODY>
<img datasrc="#teampics" datafld="teams">
<INPUT TYPE = "button" VALUE = "First Team" ONCLICK = "move( 'first' );">
<INPUT TYPE = "button" VALUE = "Previous Team" ONCLICK = "move( 'previous' );">
<INPUT TYPE = "button" VALUE = "Next Team" ONCLICK = "move( 'next' );">
<INPUT TYPE = "button" VALUE = "Last Team" ONCLICK = "move( 'last' );">
</BODY>
</HTML>

The teampic.txt file looks like this.

teams
teamphotos/adamsteam.jpg
teamphotos/ballteam.jpg
teamphotos/burgessteam.jpg
teamphotos/chicorliteam.jpg
teamphotos/currieteam.jpg
teamphotos/doranteam.jpg
teamphotos/hacknerteam.jpg
teamphotos/hendersonteam.jpg
teamphotos/langteam.jpg
teamphotos/maletteteam.jpg
teamphotos/pineauteam.jpg
teamphotos/rosengrenteam.jpg
teamphotos/saloteam.jpg
teamphotos/shubatteam.jpg
teamphotos/stewartteam.jpg
teamphotos/weissteam.jpg

Its weird that the code won't work if I refresh the page...that's when I get the error message, but works if I go back and then forward on the browser. ????

Fang
11-09-2003, 03:30 AM
This is from "Inside Dynamic HTML (http://www.amazon.com/exec/obidos/ISBN%3D1572316861/insidedynamichtmA/103-6148037-3780646)" by Scott Isaacs (http://www.siteexperts.com/home.asp)
ADOR allows you to move the current record pointer before the first record in the data set (BOF, or beginning of file) or after the last record in the data set (EOF, or end of file). Because these positions have no data associated with them, moving to these positions will result in all bindings on the page having null values, which usually means nothing is displayed. This problem can be avoided by checking the current position in the recordset prior to moving the pointer.
<SCRIPT LANGUAGE="JavaScript" FOR=NextButton EVENT=onclick>
if (stocklist.recordset.AbsolutePosition <
stocklist.recordset.RecordCount)
stocklist.recordset.MoveNext();
else
alert("Already at last record.");
</SCRIPT>