Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Newbie
 
Join Date: Apr 2007
Posts: 1
#1: Apr 10 '07
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:

Expand|Select|Wrap|Line Numbers
  1. <form name="address_search" method="$_GET" action="http://............/Geocoder/googlegeoapi.php?">
  2. <input name="HOUSE_NUM" type="text" id="HOUSE_NUM"  size="20" >
  3. <input type="submit" name="Submit" value="Submit" >
  4. </form>
  5.  
  6. <input type="text" name="x_coord" id="x_coord"><br>
  7. <input type="text" name="y_coord" id="y_coord"><br>
  8. <a href="javascript:doSubmit();">Zoom to this location</a>
  9.  
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's Avatar
Expert
 
Join Date: Mar 2007
Location: England
Posts: 1,083
#2: Apr 11 '07

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


Quote:
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_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>

<? 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="javascript:doSubmit();">Zoom to this location</a>[/HTML]
Reply