Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 07-16-2003, 10:17 AM   #1
Member (7 bit)
 
chris1977uk's Avatar
 
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.
chris1977uk is offline   Reply With Quote
Old 07-18-2003, 11:37 AM   #2
Member (10 bit)
 
Join Date: Jan 2001
Location: Birmingham, UK.
Posts: 553
Send a message via Yahoo to dj4uk
If you use:
Code:
<input type="image" src="imagename.jpg" width="20" height="20">
instead of
Code:
<img src="imagename.jpg" width="20" height="20">
then the co-ordinates are worked out automatically when the form is submitted.
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.
dj4uk is offline   Reply With Quote
Old 07-21-2003, 03:59 AM   #3
Member (7 bit)
 
chris1977uk's Avatar
 
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!!!
chris1977uk is offline   Reply With Quote
Old 07-21-2003, 04:33 AM   #4
Member (7 bit)
 
chris1977uk's Avatar
 
Join Date: Sep 2002
Location: Middlesbrough, UK
Posts: 108
ITS SORTED

thanks for the help
chris1977uk is offline   Reply With Quote
Old 07-22-2003, 05:34 AM   #5
Member (10 bit)
 
Join Date: Jan 2001
Location: Birmingham, UK.
Posts: 553
Send a message via Yahoo to dj4uk
What was the code you used in the end?
dj4uk is offline   Reply With Quote
Old 07-22-2003, 05:41 AM   #6
Member (7 bit)
 
chris1977uk's Avatar
 
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!!!
chris1977uk is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 08:03 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2