Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Pass variables from form to php script

how to pass page parameters with form data



8:24 pm on Nov 17, 2008 (gmt 0)

10+ Year Member


I have a web page with a map image. Users click on different areas of the map for a list of distributors in that area. A php script delivers the results. All easy enough.

However, we now have different distributors for different product ranges.

The page has a normal form that allows the user to select the product type and enter their zip code or manually select the region.

Question: how can I pass the value in the "product type" on the form to the links in the image area hotspot links? Or, get to the php script the value selected on the form, assuming I use a JavaScript onchange() routine to store the value should the usere change the form field? This has me really stumped.

Thanks in anticipation.


8:56 pm on Nov 17, 2008 (gmt 0)

10+ Year Member

well, what your talking is Ajax. If you are like me though and are lazy and dont want to go through tweaking all your code do it like this.

1) add an iframe at the bottom of the page.

2)when someone clicks on the map or whatever, fire an event to change the url of the iframe and reload...here is code:
<a href="#" onClick="document.getElementById('myframe').href='http://mydomain.com/myphppage.php?id=1'">click me</a>

3)on the php have a javascript function tied to the onload for that page. example:
<script language='javascript'>
function tellParentIloaded(){
var = myVarsFromPHP;

4)on the origional page add your javascript to handle the request:
<script language='javascript'>
function parentFunctionTochangeFormElements(myVars){
//javascript to change form based on the values
//given by the iframe that just loaded with your
//php data

5) Your done!

Add iframe to bottom of page where you pass variables to a php page via the url. That pages does some work and sends back data via a javascript tied to the onload comand.


Featured Threads

Hot Threads This Week

Hot Threads This Month