J
jackiepatti
QUESTION:
I have a web page containing a form that contains an image instead of a
submit button, e.g.
<form name='myform' action='get' method='otherpage.asp'>
<input type='image' src='picture.gif' name='myimage' id='myimage'>
</form>
When forms with image types are submitted, the value is not returned;
instead, when the form is submitted, the XY coordinates of the where
the user clicked on the image are sent. For example, if the user
clicked on the pixel located at 100, 150, a querystring of this form is
sent:
?myimage.x=100&myimage.y=150
Does anyone know how I can access these variables via JavaScript before
the form is submitted? I have tried everything I can think of and
Googled like crazy and have run out of ideas. I have even tried
submitting the form, extracting the variables, and then cancelling the
submission, but... it seems I just can't get there from here. The form
field does not seem to have any properties whatsoever.
I am testing in IE 6.0 and Mozilla 1.4 on W2K, but am hoping for a
solution as browser-compatible as possible; at a minimum I need IE 5
and up, Mozilla, Firefox and Safari.
CONTEXT:
I am building an art gallery.
This particular page contains an image of a color wheel showing the RGB
color space at brightness = 100%. The user click on the color wheel to
return an x,y value pair, from which I calculate the RGB value in
hexadecimal. I write the RGB value to a hidden form field in a second
form and then write a little DIV with a background set to the chosen
color to show the user.
The user can then change the RGB value by editing another form field
(brightness), from which I recalculate the RGB value, again writing it
to my hidden form field in the second form and as the background to the
little DIV.
Once the user has finished choosing their color via the color wheel and
brightness field, they submit the second form to my site where I
extract the hidden form field to search my database for art containing
that color.
The bit I cannot get to work is that I can't seem to get the x,y value
pair from the <input type=image> field in the first form on the
client-side.
I cannot implement this via a client-side image map as there are over
40000 individual pixels that would need definition in a <MAP> tag and I
have to complete this project within this lifetime. So I prefer to
calculate from the x,y coordinates.
I prefer not to implement it via a server-side image map as the user
may make changes many times before choosing to search and this would
slow the application down a great deal if they had to submit repeatedly
just so I could get the x,y coordinates from a querystring.
I think it may simply not be possible to access the x,y coordinates
from and an <input type='image'> on the client-side. Does anyone have
any other ideas about how I can access the coordinates of the image at
the point where the user clicked?
I have a web page containing a form that contains an image instead of a
submit button, e.g.
<form name='myform' action='get' method='otherpage.asp'>
<input type='image' src='picture.gif' name='myimage' id='myimage'>
</form>
When forms with image types are submitted, the value is not returned;
instead, when the form is submitted, the XY coordinates of the where
the user clicked on the image are sent. For example, if the user
clicked on the pixel located at 100, 150, a querystring of this form is
sent:
?myimage.x=100&myimage.y=150
Does anyone know how I can access these variables via JavaScript before
the form is submitted? I have tried everything I can think of and
Googled like crazy and have run out of ideas. I have even tried
submitting the form, extracting the variables, and then cancelling the
submission, but... it seems I just can't get there from here. The form
field does not seem to have any properties whatsoever.
I am testing in IE 6.0 and Mozilla 1.4 on W2K, but am hoping for a
solution as browser-compatible as possible; at a minimum I need IE 5
and up, Mozilla, Firefox and Safari.
CONTEXT:
I am building an art gallery.
This particular page contains an image of a color wheel showing the RGB
color space at brightness = 100%. The user click on the color wheel to
return an x,y value pair, from which I calculate the RGB value in
hexadecimal. I write the RGB value to a hidden form field in a second
form and then write a little DIV with a background set to the chosen
color to show the user.
The user can then change the RGB value by editing another form field
(brightness), from which I recalculate the RGB value, again writing it
to my hidden form field in the second form and as the background to the
little DIV.
Once the user has finished choosing their color via the color wheel and
brightness field, they submit the second form to my site where I
extract the hidden form field to search my database for art containing
that color.
The bit I cannot get to work is that I can't seem to get the x,y value
pair from the <input type=image> field in the first form on the
client-side.
I cannot implement this via a client-side image map as there are over
40000 individual pixels that would need definition in a <MAP> tag and I
have to complete this project within this lifetime. So I prefer to
calculate from the x,y coordinates.
I prefer not to implement it via a server-side image map as the user
may make changes many times before choosing to search and this would
slow the application down a great deal if they had to submit repeatedly
just so I could get the x,y coordinates from a querystring.
I think it may simply not be possible to access the x,y coordinates
from and an <input type='image'> on the client-side. Does anyone have
any other ideas about how I can access the coordinates of the image at
the point where the user clicked?