Adding Image to Button fails to send to correct link

Discussion in 'HTML & Website Design' started by chrisj, Jun 16, 2013.

  1. #1
    This works successfully:

    Code:
    <input type="button" name="search" value="Search Again" onclick="window.location.href='page.php?page=9';" style="margin:7px 0" style="padding:1px 2px 1px 2px">
    Code (markup):
    When I try to add an image, and test it, it doesn't take me to page.php?page=9 as before. Here's the added image code:

    <input type="image" src="/images/button2.png" name="search" value="Search Again" onclick="window.location.href='page.php?page=9';" style="margin:7px 0" style="padding:1px 2px 1px 2px">
    Code (markup):
    If you could help me correct this, it would be greatly appreciated.​
     
    chrisj, Jun 16, 2013 IP
  2. ninjacrunch.com

    ninjacrunch.com Greenhorn

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #2
    Try creating your own javascript function. example -->

    <input type="image" src="/images/button2.png" name="search" value="Search Again" onclick="submitNewURL();" style="margin:7px 0" style="padding:1px 2px 1px 2px">
    HTML:
    Then put the code below inside the <head> tag in your html -->

    <script type="text/javascript">
     
        function submitNewURL() {
            window.location = "page.php?page=9";
        }
    </script>
    HTML:
    Hope it helps.
     
    ninjacrunch.com, Jun 17, 2013 IP
  3. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #3
    Works just fine for me.
     
    ActiveFrost, Jun 17, 2013 IP