SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    calif
    Posts
    743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I add an image to this button?

    How do i add an image to this button?

    Code:
    <li><input type="submit" value="[var.lang_login]" class="button-form" /></li>

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,301
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    You can use this:

    Code:
    <input type="image" src="img.png" alt="Submit" name="submit" value="Submit">

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    calif
    Posts
    743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that. It was really helpful.

    I have another question, please.

    When I try to add an image to this:

    Code:
    <input type="button" name="search" value="Purchase Credits" onclick="window.location.href='credits.php';">
    Like this:

    Code:
    <input type="image" src="img.png" name="search" value="Purchase Credits" onclick="window.location.href='credits.php';">
    I now see the image button, but when I click it, I don't get taken to the correct page now.

    Any thoughts?

  4. #4
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,816
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    where did you want the button to take you to? you have added a .js that sends a user to "credits.php", in your OP this button would have simply submitted the form. if that's what you want then just remove the onclick .js

  5. #5
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    calif
    Posts
    743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your reply.
    I'm not clear on what you're saying, but this is an open source script that's modified.
    I didn't add .js, it came that way.
    It works correctly without the image (including the .js and onclick and credits.php).
    I'd like it to continue to work the same way, but I'd just like to add an improved image, to the button. Which I did but it somehow screws up the button's original execution, which is to take me to credits.php.
    Any other help will be appreciated.

  6. #6
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,816
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    Sorry, I see how my phrasing was all worbly there.

    you need to counter the default action of the image input ( which is to submit the form) to do this you add 'return false; ' as the last thing in your onclick e


    Code:
    <input type="image" name="search" src='image.jpg' value="Purchase Credits" onclick=" window.location.href='credits.php'; return false;">
    note that this is specific for using INPUT type='image' , you could have just used BUTTON or even IMG with your original onclick code.


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
  •