Click to See Complete Forum and Search --> : Send value from JS to ASP function


yphasukyued
12-04-2003, 09:47 AM
ASP Function

ConvertScreenCoordsToMap(ScreenX, ScreenY, MapX, MapY)
______________________________________________________

The below JS and HTML result are working fine. It is give me the screen XY coordinates, but I want to converting the screen coordinates to my mapping coordinates (Lat-Long) with the above ASP function that runing on the server. Is any one know how can I do it? It has to be done when ONMOUSEMOVE

<input type="image" src="MyMap.jpg" ONMOUSEMOVE="window.status=tempX + ',' + tempY">

<form name="Show">
X <input type="text" name="MouseX" value="0" size="4"><br>
Y <input type="text" name="MouseY" value="0" size="4"><br>
</form>

<script language="JavaScript1.2" type="text/javascript">
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else { // grab the x-y pos.s if browser is NS
tempX = e.pageX;
tempY = e.pageY;
}
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}
document.Show.MouseX.value = tempX;
document.Show.MouseY.value = tempY;
return true;
}

//-->
</SCRIPT>

Thanks

Yut

Webskater
12-04-2003, 10:16 AM
I'm not quite sure what you are trying to do - obviously capture the mouse co-ordinates and then find out where you are on a map?
You're getting the X,Y co-ords of the mouse in javascript and I am sure you know how to pass them to the server using a variety of ways - you could use location.replace('yourpage.asp?X=' tempX ' etc
But if you are trying to do something else and you want to keep your page showing you can use a hidden iframe to hold the asp page with the asp function on it and get this page to talk to the page with the map on.

Pittimann
12-04-2003, 10:16 AM
Hi!

Unfortunately, I don't know the ASP function you mentioned.

1. Can you tell me, how you have to send the data there? Is it with a form (method=post action=NameOfFunction.asp)?

2. Why not creating the map (that's your goal, isn't it) in js??

Cheers - Pit

yphasukyued
12-04-2003, 12:11 PM
Thank you very much "Pittimann and Webskater"
Map is just JPG file that generated from server side. What I want to do is get the Lat-Long (degree-minute-second) when the mouse move over the JPG. Right now I just got screen pixel XY coordinate.

Yut

Pittimann
12-04-2003, 12:20 PM
Hi!

I really thought that you talk about an image map (diving an image into different areas, you can attach events to).

Anyway, if I was a geographer, it would be easy to do the thing in js. Unfortunately I am not.

Good luck - Pit