Guestion about buttons...

Discussion in 'JavaScript' started by x0x, Oct 11, 2009.

  1. #1
    <input value="MAX BUY" onClick="document.store.item1.value=200000;characterCount(500000000);" type="button">

    <a href="#" onclick="document.store.item1.value=200000;characterCount(500000000);">MAX BUY</a>

    Let's say I have scrolled to the mid way of the page and click the button with the JS code, it fills the textbox item1 nicely, but with the second url version it takes the page to the top and I have to scroll back down. Is there anyway to make it not scroll up and stay where it is without using a button?
     
    x0x, Oct 11, 2009 IP
  2. rainborick

    rainborick Well-Known Member

    Messages:
    424
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Remove the # from the HREF attribute from your <a>nchor tag. Make it href="".
     
    rainborick, Oct 11, 2009 IP
  3. semantic7

    semantic7 Member

    Messages:
    92
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    48
    #3
    Add return false; to avoid the page jumping.
     
    semantic7, Oct 12, 2009 IP