Click to See Complete Forum and Search --> : newbie question


violet
04-29-2003, 11:05 AM
I have the following function and need help on using it.

What I want to do:

1: users enter values into textboxes
2: values are converted (with function)
3. Need to enter values into database.

The function:

//Get the easting, northing, id and UTM zone from the form
x = document.pointType.easting.value;
y = document.pointType.northing.value;
id = document.pointType.Bed_ID.value;
// Convert MCS to lat/lon
var latLonPt = map.mcsToLonLat(x, y);
window.location="add_GPS_Point.cfm?PT_LAT=" + latLonPt.getY() + "&PT_LON=" +
latLonPt.getX() + "&UTM_EASTING=" + x + "&UTM_NORTHING=" + y + "&UTM_ZONE="
+ zone + "&ID=" + id;


Can someone please help me ? What do I need to do - what should the rest of my code look like. I have set up a form, included the above function - but haven't had any success.
I am new to javascript and have read several tutorial on functions - but an still at a lost with get the function to convert the input values.

Thanks for your time,

Sue

DaiWelsh
04-29-2003, 11:11 AM
violet,

It looks like this function uses code from an object that is define elsewhere (the map object). Did you take this code from a website or a book or...? If so you need to either get the rest of the code or figure out what the

map.mcsToLonLat(x, y);

function does and replace it with one of your own.

As regards the rest, it looks like it is expecting there to be a form with name 'pointType' containing three text fields called 'easting', 'northing' and 'Bed_ID' (I think there should be a fourth called zone as well judging by later code) that are used as the input to create the latitude and longitude.

HTH,

Dai

violet
04-29-2003, 11:55 AM
Dai - is this what you were looking for?



function onDigitizedPoint(map, point)
{
var xyPt = map.lonLatToMcs(point.getX(), point.getY());

var resource = (parent.Eelgrasstop.document.Add.Feature_Type.value);
switch (resource)
{
case "Feature_Point":
var loc = "Add_Point.cfm?LAT=" + point.getY() + "&LON=" + point.getX() + "&EAST=" + xyPt.getX() + "&NORTH=" + xyPt.getY() + "&RESOURCE=" + resource;
win = window.open(loc,"AddPoint","status=no,resizable=yes,scrollbars=yes,width=750,height=280");
win.focus();
break;
default:
alert("No available at this time.");
}


How does this code work with the function?

The code was give to me by somone working on a similar project. I am trying to figure how to do what I outlined in my first post by looking at her files - but am pretty confused as how they all work together - as this in my first time using javascript.

violet
04-29-2003, 12:02 PM
Dai - or is this the code I need to accomplish my task?



<object ID="map" WIDTH="101%" HEIGHT="100%"
CLASSID="CLSID:62789780-B744-11D0-986B-00609731A21D"
CODEBASE="http://www.shim.bc.ca/viewer/v6/mgaxctrl.cab#Version=6,0,2,2"> <param name="URL"
value="http://www.shim.bc.ca/Eelgrass/Eelgrass_MG6.mwf">
<param name="Lat" value="">
<param name="Lon" value="">
<param name="MapScale" value="0">
<param name="MapWidth" value="">
<param name="Units" value="km">
<param name="ToolBar" value="On">
<param name="StatusBar" value="On">
<param name="LayersViewWidth" value="200">
<param name="ObjectLinkTarget" value="Eelgrassrpt">

<embed
SRC="http://www.shim.bc.ca/Eelgrass/Eelgrass_MG6.mwf"
BORDER="0" WIDTH="101%" HEIGHT="100%" NAME="map" TYPE="application/x-mwf">
</object></div>

DaiWelsh
04-29-2003, 04:59 PM
The last one looks like the winner, though I could not tell you what it does, so it will probably be a bit hit and miss coding for it unless you can contact the provider of this object for documentation?

violet
04-29-2003, 05:26 PM
Thanks for getting back to me Dai,

I have made some progress - I can convert the input values using the function successfully now.

Now I need to figure out how to pass the values that have been converted to a new page.

I will put this question in a new post.

I appreciate you taking the time to answer my posts.