Help with recordset.bof / eof

Y

Yaara Mac

Hi all,

I need some help with using recordset.bof / oef.

I'm using HTML file to display XML records page by page.

I need to disable the moveNext button once it reaches the end of the
file but it seems to occur one page too late.

that's the function I used for the onclick of the button:

function Next()
{


if (!mydata.recordset.EOF)
{
mydata.recordset.moveNext();
}
else
{
btn_next.disabled = true;
}

}


Any ideas?
 
J

Jim Aikin

I'm strictly a hobbyist programmer, and this answer is quite likely
wrong -- but have you tried this:

function Next()
{
if (!mydata.recordset.EOF)
{
mydata.recordset.moveNext();
if (mydata.recordset.EOF) btn_next.disabled = true;
}
else
{
btn_next.disabled = true;
}
}

Assuming that moveNext increments the file pointer, that might work.

--Jim Aikin
 
Y

Yaara Mac

Hey, thanks! it's pretty close..

Now I've noticed that before changin the code it was two pages late -
now it's only one page late.

Somehow it doesn't detect that last record as the last one.
 
E

Evertjan.

Jim Aikin wrote on 05 feb 2008 in comp.lang.javascript:
[Please do not toppost on usenet]
I'm strictly a hobbyist programmer, and this answer is quite likely
wrong -- but have you tried this:
restyled:

function Next() {
if (!mydata.recordset.EOF) {
mydata.recordset.moveNext();
if (mydata.recordset.EOF) btn_next.disabled = true;
} else {
btn_next.disabled = true;
};
};

shorter:

function Next() {
if (!mydata.recordset.EOF)
mydata.recordset.moveNext();
if (mydata.recordset.EOF)
btn_next.disabled = true;
};

or even:

function Next() {
if (!mydata.recordset.EOF)
mydata.recordset.moveNext();
btn_next.disabled = mydata.recordset.EOF;
};
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top