SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2005
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Rogue <label> tag scrolling my page!?!?!

    I have a webpage that is one big form, and the form consists mostly of labels and form elements (ie. <input type... />, etc.). Everything works great and the code is spot on, however when I click on one of the labels with my mouse, it scrolls the webpage down to the bottom in Firefox. What the heck is this!?!?! How does it scroll my webpage down to the bottom just by me clicking on a text label for one of my form elements??? I have tested it over and over and for some reason when I click on this one particular label, it scrolls the page all the way down.

    Does anyone know what the heck is happening here and why it is doing this? If so, how can I fix this annoying problem. Thanks.

  2. #2
    SitePoint Zealot milenko1054's Avatar
    Join Date
    Jan 2004
    Location
    Ohio
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you post the html for the label that's causing the problem?

    The only two on-page things I can think of that may be causing this are:
    1. The label is a link to an anchor on the bottom of the page (<a href='#bottom'>text</a>)
    2. There's a JavaScript event handler attached to the onclick event of this label or one of its containers

    But, if it's happening in Firefox only...


  3. #3
    SitePoint Zealot
    Join Date
    Nov 2005
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Milenko...

    Unfortunately I can't post a link or the HTML as it is behind a password-protected space. However I can assure that it is not the two cases above. It is outrageously wierd. An "example" of exactly what the code is:

    HTML Code:
    <label for="myname">Enter Your Name:</label>
    <input type="text" name="name" id="myname" maxlength="50" />

  4. #4
    SitePoint Guru
    Join Date
    Jun 2004
    Location
    Finland
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe you have duplicate IDs and it's jumping to the last one?

  5. #5
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Move the closing </label> tag to the end of the <input /> element.

  6. #6
    SitePoint Guru
    Join Date
    Jun 2004
    Location
    Finland
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Schulz
    Move the closing </label> tag to the end of the <input /> element.
    Huh? Why?

    for = idref [CS]
    This attribute explicitly associates the label being defined with another control. When present, the value of this attribute must be the same as the value of the id attribute of some other control in the same document. When absent, the label being defined is associated with the element's contents.

  7. #7
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Check your ID's as sorccu said because labels associate the "for" attributes value with the control that has a corresponding value for its id.

    Also validate your page in case there are missing end tags etc.

  8. #8
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    yeh, label should be separate from input.

    I can only think of what the others have said - it is pointing to an ID that is also present elsewhere.

    Without a link, it's difficult to help. Can you put a copy of the page in a non password protected area for a bit?

  9. #9
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry, sleep deprivation...

    safely ignore the post


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •