PDA

View Full Version : Value to next page



bluewalrus
09-23-2009, 06:57 PM
How can I have javascript send it's value in a form

I have this form:



<form method="post" action="submit.php">
Name:<input type="text" name="name" /><br />
City:<input type="text" name="city" id="city"/><br />
State:<input type="text" name="state" id=state" /><br />
Address:<input type="text" name="address" id="address" /><br />
Phone:<input type="text" name="phone" /><br />
<input type="hidden" name="latlong" value="???" /><br />
<input type="submit" onClick="javascript:submitdata();" />
</form>


and I want the address, city, and state to go into the var address I then want the output of that which is point to be passed in the latlong value.

This is my idea of how it might function but I'm not sure cause I don't know javascript. Hope someone here can help me out.



var address = "document.submitform.address.value + /", /" + document.submitform.city.value/" + /", /" + document.submitform.state.value";
geocoder.getLocations(address, locate);
function locate(response)
{
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);



This is what I expect address to equal with this address, city, state

bluewalrus
09-24-2009, 12:34 AM
Okay got it to here. It alerts the address fine but doesn't bring up the 1.5 so there's something wrong around there. Any ideas?


var address = document.submitform.address.value + " " + document.submitform.city.value + ", " + document.submitform.state.value;
alert(address);
geocoder.getLocations(address, get_address);
}
// This function adds the point to the map
function get_address(response)
{
alert("1.5");
// Retrieve the object
place = response.Placemark[0];
alert("2");

forum_amnesiac
09-24-2009, 05:57 AM
Is your second piece of code complete, if so then you have a "}" that is not opened. Have you enabled javascript debugging.

bluewalrus
09-25-2009, 12:40 AM
It was a piece of a chunk i didn't include the start of the function because the alerts at the beginning worked. I actually gave up on this but I don't know how to turn on debug or run traces how do you do that without using alerts?

EDIT: Figured this half out. Also I might figure this out soon but so far google hasn't helped does anyone know how to read this? Is this setting Radius's value to 500 if something happens?

oRadius.value = oRadius.value ? oRadius.value : 500;

forum_amnesiac
09-25-2009, 05:57 AM
Depends on your browser, in IE look in Tools/Internet Options/Advanced and you'll see an option to disable javascript debugging, untick that ans save.

In Firefox, there is an add-on for this but it is easier to use the error console.

In Opera you can use the error console.

This is an essential way to ensure that your javascript is error free, you get pointed to the problem lines