SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    USA
    Posts
    1,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    image type button not starting javascript action

    This works:
    <input type="button" value="Add to list" onClick="addOption(param1, param2);">

    But this doesn't:
    <img src="images/add.gif" onClick="addOption(param1, param2);">

    The error I get using the img tag is, "this.form has no properties". Yet it is right beside the input tag that does work.

    This doesn't work either:
    <input type="image" src="images/add.gif" value="Add to list" onClick="addOption(param1, param2);">

    The error I get with this is that it does the javascript action then Submits the form - I do not want it to submit, just do the javascript action.

    What can I do to get a graphic button that will complete the javascript action?

    Thanks.

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    add this attribute to the input element's containing form: onsubmit="return false;"


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
  •