如何在使用POST提交后获取图像映射中的值

This is the code. I just want to get the value of the area in imagemap using php POST but it return null what should I do?

   <?php 
        if(isset($_POST["part"]))
        {
             $part=$_POST["part"];
        echo "<script> alert('".$part."') </script>";
        }
        ?>

    <form action="" name="form" method="POST">

    <img name="newmale" class="mapper" src="newmale.png" width="261" height="548" id="newmale" usemap="#m_newmale" alt="" /><map name="m_newmale" id="m_newmale">

    <area   shape="poly" class="noborder icolor00ff00"coords="114,29,122,309" nohref onClick="form.submit();" name="part"  value="Head"title="Head" alt="Head" />

    </form>

The area tag is not a form field so it does not get submitted when you submit the form.

What you could do, is add an href attribute (not sure if that is even necessary...) and use javascript to:

  • catch the click event;
  • set the value of a hidden form element based on the clicked area element (href value, data attribute, etc.);
  • submit the form.