View Full Version : radio button makes page jump to top

10-10-2002, 09:22 PM
This form has radio buttons half way down the page. When one of the radio buttons is selected, the page jumps back up to the top. Is it re-loading? How do I stop it?

10-10-2002, 09:47 PM
*scratches head*

Which form?

10-10-2002, 10:02 PM
Like, I am from California and say "like, this" too much... causing listeners to return puzzled looks and thoughts of blonde jokes.


When selected, this form's radio-button calls a function which refreshes the page.

function onChange()

However, the radio button is at the bottom of the page. And onChange, jumps the page back to the top. Very clumsy.

I could direct it to jump back down, but would prefer a more seamless appearance when it refreshes.

Like, any help appreciated, dude.

10-10-2002, 10:24 PM
I wasn't joking when I said that I couldn't understand which form you were talking about (I'm not a native english speaker), but since you provided much more info about your JavaScript function by now, I can have a look at it.


This causes the form to submit. After that, the page defined in your action attribute handles the form submit and eventually returns an answering page. From your error description, it looks like you haven't defined a page in your action attribute, so the page submits to itself, i.e. reloads the page (and jumps back to the top).

If you want to prevent that, remove the code mentioned above. On the other hand, if you want to submit the form if the value of the radio box gets changed, you'll have to keep it, but then you have to use an anchor and redirect the page after loading to it.

Does that help?

10-10-2002, 10:38 PM
Yes, slang is a difficult part of language even for native speakers. I should watch my tongue (fingers in this case) and be more precise, maybe use "Within a form..." or something. Sorry.

Yes, your answer does help. My concern is that using an anchor to redirect the page after loading to it looks bad. It displays the top of the page for a split second, and then you see the jump down.

Perhaps there is a way to delay the reload so that it has the correct page location before displaying? This might avoid the split-second display of the top?

10-10-2002, 10:47 PM
can we maybe see the rest of the page?

10-11-2002, 01:26 AM
too much code to post....

The page I am using combines several include files/sections. Each submit (including the radio buttons) needs to work independently for each section.

Is there any way to delay a refresh, I mean, to delay the display, until all of the page pieces are assembled? Then display the page already in its proper below-fold location?

Anchors are fine, however on all pages they first display the top of the page for a split second, and then jump down to the anchor tag location. The effect is jarring and clunky looking, which is what I am trying avoid.

10-11-2002, 01:49 AM
Not that I know of...

10-11-2002, 12:41 PM
zazen, when I try a dummy form with action="formReceive.html#anchorName", the redirect to the anchor is almost instantaneous. However, on my formReceive.html, there is not much markup to render, so the page loads very fast.

There is a technique for delaying the display of a page. Make the body via CSS invisible (setting the visibility to hidden), and then include this snippet

window.onload = function() {
document.body.style.visibility = "visible";

This works only in modern browsers, i.e. not in NN4.x. And it has the great drawback that all javascript-disabled visitors won't see anything of the page, so consider if that's really worth the trouble...

10-14-2002, 08:02 PM
Ah, javascript-disabled visitors
the bane of all our javascripting existence!

I'll give this a try, but probably will go Java.... let me know if you are interested in the solution used and I'll write back.

Like, thanks.

10-25-2002, 12:01 AM
Billy Collins, our current U.S. Poet Laureate, likes to take note of the inadvertant haikus which are the result of advertising and popular culture at large. He recently discovered this one while overhearing a conversation between two students at the University where he teaches:

When she found out she
was like oh my God and I
was like oh my God

10-25-2002, 12:12 AM
That's a little too deep (?) for me. ;)