Window scrolling (clarification)

E

Ethan

This is a clarification of a previous message, which was not expressed
very well. I have a set of checkboxes near the bottom of the page and
a function that checks or unchecks all of them. But when the function
runs, the window scrolls to the top of the page.

How can I set my checkboxes but leave the window's scroll position
exactly where it is? Or at least have it scroll to the bottom (where
the checkboxes are).

I've tried using window.scrollTo(), but the window always scrolls to
the top no matter what. It's the same in Navigator and IE.

Here's my code:

function checkAll(whichForm, startIndex, endIndex)
{
for (var j = startIndex; j <= endIndex; j++)
{
document.forms[whichForm].elements[j].checked = true;
}
window.scrollTo(0, 1000);
}

Thanks,

Ethan
 
F

Fred Serry

Ethan said:
This is a clarification of a previous message, which was not expressed
very well. I have a set of checkboxes near the bottom of the page and
a function that checks or unchecks all of them. But when the function
runs, the window scrolls to the top of the page.

How can I set my checkboxes but leave the window's scroll position
exactly where it is? Or at least have it scroll to the bottom (where
the checkboxes are).

I've tried using window.scrollTo(), but the window always scrolls to
the top no matter what. It's the same in Navigator and IE.

Here's my code:

function checkAll(whichForm, startIndex, endIndex)
{
for (var j = startIndex; j <= endIndex; j++)
{
document.forms[whichForm].elements[j].checked = true;
}
window.scrollTo(0, 1000);
}

Thanks,

Ethan

Hi,

Can you show how this function is called? I suspect you are using something
like:

<a href="#" onclick="checkAll(blabla)">

If so, add a "return false" to prevent the link to do its actual work

<a href="#" onclick="checkAll(blabla);return false">

Fred
 
E

Ethan

Fred Serry said:
"Ethan" <[email protected]> schreef in bericht .... ....
Hi,

Can you show how this function is called? I suspect you are using something
like:

<a href="#" onclick="checkAll(blabla)">

If so, add a "return false" to prevent the link to do its actual work

<a href="#" onclick="checkAll(blabla);return false">

Fred

That's the answer. Thank you very much.

Ethan
 

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,007
Latest member
obedient dusk

Latest Threads

Top