homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Pass variables from form to php script
how to pass page parameters with form data

10+ Year Member

Msg#: 3788204 posted 8:24 pm on Nov 17, 2008 (gmt 0)


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.



10+ Year Member

Msg#: 3788204 posted 8:56 pm on Nov 17, 2008 (gmt 0)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved