Link within a page with GET variable

Discussion in 'Web Design and Development' started by citizenzen, Apr 6, 2010.

  1. citizenzen macrumors 65816

    Joined:
    Mar 22, 2010
    #1
    I'm creating a form where I display different fields depending on the URL variable that is passed through a link...

    <a href="foo.php?a=bar&b=x">Link1</a>
    <a href="foo.php?a=bar&b=y">Link2</a>
    <a href="foo.php?a=bar&b=z">Link3</a>

    These links are a ways down the page, and when clicked, the page jumps to the top because of the new URL. I can "anchor" the page on the links by adding # anywhere in the URL...

    <a href="#?a=bar&b=x">Link1</a>

    This will keep the page from jumping up, but it breaks my ability to GET the variable. There must be a way to both GET the variable and maintain the focus on the link, but I am too much of a noob to know how.

    Anybody help a brother out?
     
  2. citizenzen thread starter macrumors 65816

    Joined:
    Mar 22, 2010
    #2
    This works... sorta...

    <a href="foo.php?a=bar&b=z#x" name="x">Link3</a>

    But then it jumps the link to the top of the page. Alternatively, I can name another element somewhere above the link so the jump is less severe. But is there a way to anchor the page so it doesn't jump at all?
     
  3. CANEHDN macrumors 6502a

    CANEHDN

    Joined:
    Dec 12, 2005
    Location:
    Eagle Mountain, UT
    #3
    The only way to have your page do no jump at all is through javascript. Using the html links will move the page a little bit when jumping to the id you've set it to jump to.
     
  4. Darth.Titan macrumors 68030

    Darth.Titan

    Joined:
    Oct 31, 2007
    Location:
    Austin, TX
    #4
    I'm having a problem visualizing what you mean.
     
  5. jaikob macrumors 6502

    jaikob

    Joined:
    Jul 1, 2008
    Location:
    Freeland, MI
    #5
    Yeah your going to have to use anchors on this one unless you want to use ajax.
     

Share This Page