SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 1999
    Location
    Los Angeles, CA
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Capturing X,Y coordinates of <INPUT TYPE="image"> in a form.

    When using an image as a submit button in a form, the next page has access to the coordinates of the mouse click relative to the top left corner of the image as submit.x and submit.y.

    Is there any way of capturing these values without submitting the form? Like on the same page where the form is, I want to be able to fill two text form fields with the X and Y coordinates of the click before the user clicks on actual submit.

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want to be able to fill two text form fields with the X and Y coordinates of the click before the user clicks on actual submit.
    I think there is a function in js you can use:

    mindMeld.user();

    which will return the coordinates of the click before the user actually presses down on the mouse.

    More seriously: you can always cancel the submit after the user clicks on the image by returning false from the onsubmit event handler.

  3. #3
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    Oh my god I think I just wet myself reading that 7stud! Very well put!

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 1999
    Location
    Los Angeles, CA
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 7stud
    I think there is a function in js you can use:

    mindMeld.user();

    which will return the coordinates of the click before the user actually presses down on the mouse.

    More seriously: you can always cancel the submit after the user clicks on the image by returning false from the onsubmit event handler.
    I know I can cancel the submit, the question is how to get the X and Y coordinates after the user clicks on the image.


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
  •