Click to See Complete Forum and Search --> : passing infromation from FORM to URL


smallfish
08-17-2006, 10:29 AM
can anyone give me some help on simply:
1. accepting address information via html FORM
2. passing that information to pop-up window
3. filling in the pop-up's url with this:
http://maps.google.com/maps?saddr=[street]+[city]+[state]+[zip]&daddr=103+Cherokee+Blvd+Chattanooga+TN+37405

final result is that a person will enter their starting address into a web form and upon clicking SUBMIT, they will be wisked away to a pop-up screen showing direction from their address to the destination address.

any thoughts?


<form method="get" action="http://maps.google.com/maps?saddr=100+Cherokee+Blvd+37405&daddr=5918+Lake+Resort+Drive+37343" enctype="x-www-form-encoded">
<input type="hidden" name="sort" value="order:street,city,state,zip" />


street<input type="text" name="street" /><br />
city<input type="text" name="city" /><br />
state<input type="text" name="state" /><br />
zip<input type="text" name="zip" /><br />
<input type="button" type="submit" value="submit" />
</form>

Wiz Creations
08-17-2006, 11:00 AM
I know mapquest has that feature.
http://www.mapquest.com/features/main.adp?page=lf_dir

In order to do it with google, it will have to be something like the following:<form action="http://maps.google.com" method="get" onSubmit="this.target='_blank';">
Address, City, State: <input type="text" name="saddr" value="" /><br />
<input type="hidden" name="daddr" value="End Address Here, City, State">
<input type="submit" name="submit" value="Get Directions">
</form>
The only way I would think you could separate the input for address, city, and state is to use php. After they click submit, php would tie the information together.

smallfish
08-17-2006, 11:39 AM
Wiz-
you're on the right track. after tweaking it a bit, this version works perfectly. But it would be very nice to be able to have 3 seperate INPUT fields to take the information. any thoughts from you or anyone else?

here's the existing, working code


<form action="http://maps.google.com" method="get" onsubmit="this.target='_blank';">
<input type="hidden" name="daddr" value="103 Cherokee Blvd, Chattanooga, TN, 37405">
Address, City, State: <input type="text" name="saddr" value="" /><br />
<input type="submit" name="submit" value="Get Directions">
</form>

Wiz Creations
08-17-2006, 05:47 PM
You need to ask in the php thread. What you need to do (well, what I would try to do) is set up the form something like this:<?php { ?>
<form action="http://maps.google.com" method="get" onsubmit="this.target='_blank';">
<input type="hidden" name="daddr" value="103 Cherokee Blvd, Chattanooga, TN, 37405">
<input type="hidden" name="saddr" value="<?php echo (isset($_POST['saddr'])) ? .$_POST['address']","$_POST['city']","$_POST['state']. ?>
Address: <input type="text" name="address" value="" /><br />
City: <input type="text" name="city" value="" /><br />
State: <input type="text" name="state" value="" /><br />
<input type="submit" name="submit" value="Get Directions">
</form>
<?php } ?>

I highly doubt this php will work. As in the php thread for help from someone who knows what they are doing.

Make sure you save the page with a .php extension.