getting at <input type=image ...> coordinates

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Csaba Gabor

    #1

    getting at <input type=image ...> coordinates

    When I click on the image form element
    <INPUT type=image name=point src="map.png">
    point.x and point.y values get submitted to the server
    specifying where on the image I have clicked.

    Is there any (simple) way to get ahold of that point.x and
    point.y BEFORE they are sent to the server (and prevent
    that from happening)? Ie. I just want the points where
    someone clicks on an image and not interested in a submission
    to the server.

    Thanks,
    Csaba Gabor


  • Stuart Palmer

    #2
    Re: getting at &lt;input type=image ...&gt; coordinates

    What are you trying to do exactly? What do you plan to do with the x and y
    values? Would an imagemap on the image not suffice?

    Let us know.
    Stu


    Comment

    • Csaba Gabor

      #3
      Re: getting at &lt;input type=image ...&gt; coordinates

      Hi Stu. I want to mark two points on a map (so I can zoom in to a
      subportion,
      or not zoom, but select all the interesting items). So I'd like to get the
      coordinates
      first and just stuff them into some edit fields so the user can adjust them.
      Also, having written a poor man's immediate fix version below that only
      works
      for IE, I can see that I'll also want to have the current position show in a
      div.

      My current hack:
      <input type=image name=mymap onclick="return mapClick();">

      and the script does:
      function mapClick() {
      document.forms[0]['pt'].value = Array(event.off setX,event.offs etY);
      return false;
      }


      I'm interested in the original question on a theoretical basis, but my
      immediate interest is more practical in that the app is for my own editing
      purposes.
      I suspect you're correct that there are other ways to do this, and I'd
      love to hear - my current knowledge of images/maps could stand bolstering.
      I'm not sure I understand how to capture mouse coordinates with a
      client side image map, though.

      Csaba

      "Stuart Palmer" <tryandspamme@y oucant.com> wrote in message
      news:2i3cjaFin2 drU1@uni-berlin.de...[color=blue]
      > What are you trying to do exactly? What do you plan to do with the x and y
      > values? Would an imagemap on the image not suffice?
      >
      > Let us know.
      > Stu
      >
      >[/color]


      Comment

      • Jukka K. Korpela

        #4
        Re: getting at &lt;input type=image ...&gt; coordinates

        "Csaba Gabor" <Csaba@z6.com > wrote:
        [color=blue]
        > Hi Stu.[/color]

        Please spend some time in learning how to post to Usenet:

        Followups trimmed. Since you question was about JavaScript, not HTML, you
        should have posted to the JavaScript group only.
        [color=blue]
        > I want to mark two points on a map (so I can zoom in to a
        > subportion,[/color]

        Actually, I think you probably need a server-side script
        [color=blue]
        > My current hack:
        > <input type=image name=mymap onclick="return mapClick();">
        >
        > and the script does:
        > function mapClick() {
        > document.forms[0]['pt'].value =
        > Array(event.off setX,event.offs etY); return false;
        > }[/color]

        So you had the answer, but you didn't bother telling it in the original
        question.
        [color=blue]
        > I'm interested in the original question on a theoretical basis,[/color]

        What question? Your JavaScript code prevents form submission when the
        image is clicked on, provided that JavaScript is enabled. What "theory"
        do you need in addition to that? Did you seriously expect to be able to
        do such things in HTML, or what?

        If you are unhappy with your own solution, consider explaining what is
        your problem with it.
        [color=blue]
        > my immediate interest is more practical in that the app is for my own
        > editing purposes.[/color]

        So it didn't really belong to comp.infosystem s.www.authoring.* at all.

        --
        Yucca, http://www.cs.tut.fi/~jkorpela/
        Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

        Comment

        Working...