SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    input type="image" ??

    Hello

    when using the input type image like so...

    <input type="image" value="url" name="url" alt="url" src="../../images/admin/url.gif">

    is it only possible to use it with submit, ie can it be made to do other button functions like reset or none (for a customised button)??

    thanks in advance
    a+
    Garrett

  2. #2
    SitePoint Member doggi's Avatar
    Join Date
    Oct 2001
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure you can. Just put an onclick event on the input type="image" like this example (it will reset your form):

    onclick="javascript:document.forms[0].reset();"

    but be aware: it will also do a submit if you defined an action in the form tag. So you will have to add your own submit code to another button.

  3. #3
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    >Lbut be aware: it will also do a submit if you >defined an action in the form tag. So you will have >to add your own submit code to another button.

    thats what i was thinking, the other annoying thing is that its writes submit to the status bar even when its not going to be a submit and there seems to be no way to stop this from happening.

    a+
    Garrett

  4. #4
    SitePoint Member doggi's Avatar
    Join Date
    Oct 2001
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But if you want to use an image as a button, don't use the input type="image". Just make a <img> a put an onclick event on that image. Then you can do anything you want (submit, reset, form validation or whatever...)

  5. #5
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    good idea, did'nt think of that!! thats what i'll do as it will fix both problems for me.

    Thanks!
    Garrett


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
  •