|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (7 bit)
Join Date: Sep 2002
Location: Middlesbrough, UK
Posts: 108
|
Javascript, coordinates on an image
What i want to be able to do is click on an image in a browser, and the x coordinate to appear in a text box, and the y coordinate appear in another textbox.
i do believe this is possible, but my javascript is not that advanced!! i'm guessing its the onclick event, but thats about as far as i know. thanks in advance. |
|
|
|
|
|
#2 |
|
Member (10 bit)
|
If you use:
Code:
<input type="image" src="imagename.jpg" width="20" height="20"> Code:
<img src="imagename.jpg" width="20" height="20"> To have access to the co-ordinates immediately without the form submitting then I think you would have to add javascript to the form tags onSubmit attribute to make sure it doesn't submit but instead calls a function that can grab the co-ordinates from the form elements (in much the same way that client side validation does) and populates the textboxes. |
|
|
|
|
|
#3 |
|
Member (7 bit)
Join Date: Sep 2002
Location: Middlesbrough, UK
Posts: 108
|
window.opener.document.routes.city4x.value = window.event.x;
window.opener.document.routes.city4y.value = window.event.y; this causes an error, object not defined, and its the window.event.x; that it doesnt like. YET..... window.status = "X=" + window.event.x + " Y=" +window.event.y; works fine, and displays right message in the status bar!!! how can that be!!! |
|
|
|
|
|
#4 |
|
Member (7 bit)
Join Date: Sep 2002
Location: Middlesbrough, UK
Posts: 108
|
ITS SORTED
thanks for the help
|
|
|
|
|
|
#5 |
|
Member (10 bit)
|
What was the code you used in the end?
|
|
|
|
|
|
#6 |
|
Member (7 bit)
Join Date: Sep 2002
Location: Middlesbrough, UK
Posts: 108
|
function route() {
window.status = "X=" + window.event.x + " Y=" +window.event.y; window.opener.document.routes.city2x.value = window.event.x; window.opener.document.routes.city2y.value = window.event.y; } // basically!!! |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|