GateKeeper
09-10-2002, 01:50 PM
This might be the wrong place to ask this question, if it is, just let me know and I will ask it on the proper forum.
I have my little distance measuring function working properly and am now trying to implement a way to mark the path between the origin point and the destination point. The problem arises when the marking function is called. Instead of placing the divs on the existing page, the function opens a new page with all the divs right where they are supposed to be realative to that page. The code I am using is below. Of course, I am still having a blonde hair day and it is probably something simple, but if anyone can give me a little guidance here, I would be thankful.
<script language="javascript">
var dxcoord = 0
var dycoord = 0
var oxcoord = 0
var oycoord = 0
var dist = 0
function getpoints()
{
if (window.event.shiftKey == true)
{
dxcoord=window.event.offsetX
dycoord=window.event.offsetY
}
else
{
oxcoord=window.event.offsetX
oycoord=window.event.offsetY
}
if (dxcoord!=0 && dycoord!=0 && oxcoord!=0 && oycoord!=0)
finddist()
}
function finddist()
{
dist=Math.round(Math.sqrt(Math.pow((oxcoord-dxcoord),2)+Math.pow((oycoord-dycoord),2)))
marktrail()
}
function marktrail()
{
nomoves=Math.round(dist/14)
xmove=Math.round((oxcoord-dxcoord)/nomoves)
ymove=Math.round((oycoord-dycoord)/nomoves)
for (i=0;i<nomoves;i++)
{
xmark=oxcoord+(xmove*i)
ymark=oycoord+(ymove*i)
markstring='<div style="width:14;height:14;position:absolute;z-index:1;top:'+ymark+';left:'+xmark+';visibility:visible"><img src="trail-marker.gif" height="10" width="10" border="0"></div>'
document.write (markstring)
}
}
</script>
GK
I have my little distance measuring function working properly and am now trying to implement a way to mark the path between the origin point and the destination point. The problem arises when the marking function is called. Instead of placing the divs on the existing page, the function opens a new page with all the divs right where they are supposed to be realative to that page. The code I am using is below. Of course, I am still having a blonde hair day and it is probably something simple, but if anyone can give me a little guidance here, I would be thankful.
<script language="javascript">
var dxcoord = 0
var dycoord = 0
var oxcoord = 0
var oycoord = 0
var dist = 0
function getpoints()
{
if (window.event.shiftKey == true)
{
dxcoord=window.event.offsetX
dycoord=window.event.offsetY
}
else
{
oxcoord=window.event.offsetX
oycoord=window.event.offsetY
}
if (dxcoord!=0 && dycoord!=0 && oxcoord!=0 && oycoord!=0)
finddist()
}
function finddist()
{
dist=Math.round(Math.sqrt(Math.pow((oxcoord-dxcoord),2)+Math.pow((oycoord-dycoord),2)))
marktrail()
}
function marktrail()
{
nomoves=Math.round(dist/14)
xmove=Math.round((oxcoord-dxcoord)/nomoves)
ymove=Math.round((oycoord-dycoord)/nomoves)
for (i=0;i<nomoves;i++)
{
xmark=oxcoord+(xmove*i)
ymark=oycoord+(ymove*i)
markstring='<div style="width:14;height:14;position:absolute;z-index:1;top:'+ymark+';left:'+xmark+';visibility:visible"><img src="trail-marker.gif" height="10" width="10" border="0"></div>'
document.write (markstring)
}
}
</script>
GK