1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How do I create a submit button with an image

Discussion in 'JavaScript' started by petschephp, Mar 22, 2009.

  1. #1
    I am trying to create a submit button as an image instead of the default button.

    Any help is appreciated.
     
    petschephp, Mar 22, 2009 IP
  2. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    
    <form id="form1" action="whereever.php" method="post">
    <img src="myimage.jpg" onclick="form1.submit();" />
    </form>
    
    Code (markup):
     
    camjohnson95, Mar 22, 2009 IP
  3. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    alternatively:
    
    <form id="form1" action="whereever.php" method="post">
    <a href="javascript: form1.submit();"><img src="myimage.jpg" /></a>
    </form>
    
    Code (markup):
     
    camjohnson95, Mar 22, 2009 IP
  4. koolman

    koolman Peon

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hey, the shortest one:

    
    <input type="image" src="myimage.jpg" />
    
    Code (markup):
    No Javascript!
     
    koolman, Mar 22, 2009 IP
  5. kiwin

    kiwin Peon

    Messages:
    281
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    kiwin, Mar 23, 2009 IP
  6. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #6
    It's best to avoid javascript if possible because users might have their javascript disabled.
     
    ads2help, Mar 24, 2009 IP
  7. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #7
    Yeh definately. I have never used images to submit a form before and i didn't realise there was a way it could be done in HTML. My first instinct was JS.
    You learn something new everyday.
     
    camjohnson95, Mar 24, 2009 IP