Hey guys !

Help me please.

I'm brazilian, so forgive my mistakes in English.

I have a form, and in a php form the user chooses city and state (source / destination), so the user clicks the search, so system searches the carriers that serve those cities and states, along with carriers appears a map.
Now begins my problem. Once the user clicks on "Tracing Route" I take away from city to city, sendig $. post(), get the distance and update the divs "price" (are dynamically created, depending on how many carriers serving that route) I did it just to test.

In the database of each carrier has a field "precoMetro" which is as a carrier charges for meters. Now I wanted to know one way rather than put away, I put the same price, do the math.
Staff if it is something very simple I apologize, I do not understand much of javascript / jquery / ajax.

I'll post my codes:

form that calls the function:


<div class="left">
<form id="formulario" name="formulario" onsubmit="calcRoute(); return false;" >
<label for="inputStart" class="inputStart" ></label>
<input type="text" readonly="readonly" class="text" value="'.htmlentities($corigem).','.htmlentities($eorigem).'"
id="inputStart" />
<br />
<label for="inputEnd" class="inputEnd"></label> <input type="text" readonly="readonly" class="text" value="'.htmlentities($cdestino).','.htmlentities($edestino).'"
id="inputEnd" />
<input type="submit" id="tracar" name="tracar" value="Traçar Rota" />
<input type="text" id="distancia" name="distancia" />




my function:

function calcRoute() {
if (marker) marker.setMap(null);
route = true;
var start = document.getElementById("inputStart").value;
var end = document.getElementById("inputEnd").value;

var request = {
travelMode: google.maps.DirectionsTravelMode.DRIVING
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
var distancia;

var rota = response.routes[0];
var etapa = rota.legs[0];

distancia = etapa.distance.value;

document.getElementById("distancia").value = distancia;


var distancia = $("#distancia").val();

$.post("calcula.php", { distancia:distancia, ';for( $i = 0; $i < mysql_num_rows($result); $i++ ){echo 'preço'.$cod.'reço'.$cod.',';}echo '}, function(get_retorno) {';

for ( $i = 0; $i < mysql_num_rows($result); $i++ )

$cod = mysql_result($result, $i, 'cod_transp');
$nome = mysql_result($result, $i, 'nome');
echo '$("#preço'.$cod.'").show("slow").text(get_retorno);'
echo "\n";

echo '


Any help will be apreciated !