Announcement Announcement Module
Collapse
No announcement yet.
input type=image Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • input type=image

    All,
    This should be simple but...how do I name the backing form to get the .x and .y values for an image click?

    Thanks,
    Jon

  • #2
    Hmm...still haven't found a good solution to this issue. I need the x and y pixel locations when an image is clicked.

    Suggestions?
    Thanks

    Comment


    • #3
      Hey Jon,

      I'm not that familiar with image mapping, but one idea you might try is using JavaScript with an onclick event placed on the desired image to record the coordinates of the click, modify some (most likely hidden) form variables (which will probably correspond to the properties of your bean) and then perform the submission with JavaScript.

      If you do try that, let me know how it goes ?

      Comment


      • #4
        Hi Jon,

        Originally posted by jonnio View Post
        All,
        This should be simple but...how do I name the backing form to get the .x and .y values for an image click?
        I haven't actually tested this, but theoretically, you should be able to bind the .x and .y values easily to your form object if you define a property of type Point. For example:

        Code:
        public class Point implements Serializable {
          private int x;
          private int y;
          // public getters and setters for x and y...
        }
        In your form backing object, you would then need to create a property of type Point that has the same name (e.g., imageName) as your input-image form field. Spring binding should then be able to bind to imageName.x and imageName.y on your form backing object.

        Make sense?

        Give it a try and let us know how it goes.

        cheers,

        Sam

        Comment


        • #5
          Yep, solved the issue just fine putting a class with .x and .y in it with the same name as the image tag (IMG). I didn't really like having to name the image the same as the form parameter variable but it will do. I had to jockey some values from hidden to submit buttons and various other form submit tags but all worked out.

          Jon

          Comment

          Working...
          X