Click to See Complete Forum and Search --> : passing variables that have been converted by function


violet
04-29-2003, 05:35 PM
I need to figure out how to pass the values that have been converted (using a function) to a new page.

Can you call a function and submit the new values at the same time?

Any suggestions?

What I want to do:

1. user inputs values
2. values are converted using a function
3. converted values are passing to new page
4. converted values are entered in to database


My code so far:


<SCRIPT LANGUAGE="JavaScript">
function getMap()
{
if (navigator.appName == "Netscape")
return parent.mapframe.document.map;
else
return parent.mapframe.map;
}

function myfunction()
{
var map = getMap();
//Get the easting, northing, id and UTM zone from the form
x = document.pointType.easting.value;
y = document.pointType.northing.value;

// Convert MCS to lat/lon
var latLonPt = map.mcsToLonLat(x, y);

// pull out lat/lon vals
lon = latLonPt.getX();
lat = latLonPt.getY();


}
</SCRIPT>
</HEAD>

<BODY>
<FORM NAME="pointType" METHOD="POST">

<CFOUTPUT>
<B>
<table border="0" width="100%" align="right" cellpadding="0" cellspacing="0">
<tr>
<td>

<FONT face="Verdana" size="1" color="white">Easting </FONT><INPUT TYPE="text" size="10" NAME="easting" style="FONT-SIZE: xx-small">
<FONT face="Verdana" size="1" color="white">Northing </FONT><INPUT TYPE="text" size="10" NAME="northing" style="FONT-SIZE: xx-small">

</CFOUTPUT>


<!--- the following code - calls function - but how do I passed the converted values (ie: lon and lat)? --->

<input type="button" value="Click Here" onclick="myfunction()">

</FORM>
</DIV>

</BODY>
</HTML>

khalidali63
04-29-2003, 05:43 PM
Two options for you.
1. after values are changed using functions assign them back to the form fields or better yet, to hidden form fields,then submit the form to the next page using "GET" mthod and parse the url for the values being submited.
(Search the forum for passing variable via URL)
2. Make the next page a child window of your current page,i.e open a the ne4xt page using window.open....
(Search the forum for parent/child window interaction)
that way you can access any child window elements and assign them the values from the parent window.

violet
04-30-2003, 12:13 PM
Thank guys, both your replies were helpful.

I have no problem now passing the user input values, but I still haven't figured out how to pass the coverted values. (converted by a function)

Could you give me some more detail on how to do this? I'm still not clear.

Thanks again for your time.

Sue

violet
05-01-2003, 01:37 PM
Thanks for your help Dave

I think i have to take a step backwards - my function is not working and I don't know why

I will get to your answer when I fully understand why my function is not working

Bear with me - I'm new to javascript