Hi Aaron,

The following code should help:

$(document).ready(function(){
    $('area').each(function(){
        $(this).attr("href", "#");
        $(this).click(function(){
            $('#ajaxresult').load('map.php', {'state':$(this).attr('alt')});
             return false;
        });
    });
});

What it does:
1. select all the area elements on the page
2. clear the href attribute
3. assign a click event to each area which....
4. loads the result of an AJAX POST to a php script (map.php) in the 
element with ID ajaxresult.

In the example, I've used the alt attribute of the area tag for the name 
of the state (which is POSTed to the php script). I've also made all 
area tags on the page behave like this - if you have other image maps on 
the page, then they will be affected too. If you want to replace the 
image map with something from your PHP script, make sure the image and 
imagemap are in a container div, then load the output of the PHP script 
into the container div (you should empty the container first).

HTH



on 18/09/2008 16:24 Aaron said::
> well what can I do to use javascript  to submit a name to my php
> code???
>
> I want to use the image map as a gui so I want it to act just like a
> form where I can name each state and then pass that name using post
> method to my php script which will do a database lookup and then once
> the list is create then I will take off the image map and put in the
> table with the list displayed.
>
> this is what I want to do but I can't figure out how I can pass the
> name to my php script...
>
>
>   

Reply via email to