How to send values from a form to PHP script and return answer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brendwal
    New Member
    • Apr 2007
    • 1

    How to send values from a form to PHP script and return answer

    Hi, I am stumped at how to do this:

    I have a simple webform that I want the user to enter one value (an address). I then want the form to send those values to a PHP script that processes the address and returns 2 numeric values back to the original webform populating two textboxes in a second form on the orginal page. I have the PHP script working to calculate the values, but I don't know how to send them properly and return the new calculated values and update the two textboxes with the new calcualted values.
    I also don't want this main page with the form to have to do a refresh if that is possible.

    So something like this in the main form page:

    Code:
    <form name="address_search" method="$_GET" action="http://............/Geocoder/googlegeoapi.php?">
    <input name="HOUSE_NUM" type="text" id="HOUSE_NUM"  size="20" >
    <input type="submit" name="Submit" value="Submit" >
    </form>
    
    <input type="text" name="x_coord" id="x_coord"><br>
    <input type="text" name="y_coord" id="y_coord"><br>
    <a href="javascript:doSubmit();">Zoom to this location</a>
    So what is the best method to SEND the address value from the form to the PHP script? And how do I return the two calculated values and have them dynamically update the two textboxes with the results? Thanks for any help!
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    So what is the best method to SEND the address value from the form to the PHP script.And how do I return the two calculated values and have them dynamically update the two textboxes with the results
    I might be mis-understanding you but you are adding unnescary layers of complication. Why not include a php script in the web page, let that do the calculation then show the results on the same page? [HTML]<form name="address_s earch" method="$_GET" action="http://............/Geocoder/googlegeoapi.ph p?">
    <input name="HOUSE_NUM " type="text" id="HOUSE_NUM" size="20" >
    <input type="submit" name="Submit" value="Submit" >
    </form>

    <? include 'calculate.php' ;?> #calculates $x and $y

    <input type="text" name="x_coord" id="x_coord" value="<? echo $x;?>"> <br>
    <input type="text" name="y_coord" id="y_coord" value="<? echo $y;?>" >
    <a href="javascrip t:doSubmit();"> Zoom to this location</a>[/HTML]

    Comment

    Working...