Link within a page with GET variable

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

  1. citizenzen macrumors 65816

    Mar 22, 2010
    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

    Mar 22, 2010
    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


    Dec 12, 2005
    Eagle Mountain, UT
    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


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


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

Share This Page