How to use Jquery to get select option value and pass to PHP?
<p>I have two database tables, grouptypes and groups.  A grouptype can have multiple groups, but a group only belongs to one grouptype.  I have two select tags, one is grouptypes and another one is groups.</p>

<p>What I want to do is that whenever a user selects a grouptype in the grouptypes dropdown menu, it triggers a handler to retrieve the corresponding groups that belong to that grouptype, and pass it to the second select dropdown list.</p>

<p>I have the code as follows. It has not been completed and there are some errors.  Can anyone help?</p>

<pre><code>  &lt;?php
    $result = $_POST['grouptype'];
    echo $result;
  ?&gt;

  GroupType: &lt;select id="groupTypes"&gt;

    &lt;?php foreach($grouptypes as $type) : ?&gt;

    &lt;?php echo "&lt;option value='" . $type-&gt;name . "'&gt;" .$type-&gt;name. "&lt;/option&gt;"; ?&gt;

    &lt;?php endforeach ?&gt;

  &lt;/select&gt;&lt;br /&gt;

  &lt;br /&gt;
  Group: &lt;select id="groups"&gt;
    &lt;?php $count = 0; ?&gt;
    &lt;?php foreach($groups as $group) : ?&gt;
    &lt;?php $count++; ?&gt;
    &lt;?php echo "&lt;option value='" . $group-&gt;name . "'&gt;" .$group-&gt;name. "&lt;/option&gt;"; ?&gt;

    &lt;?php endforeach ?&gt;

  &lt;/select&gt;&lt;br /&gt;



  &lt;script type="text/javascript"&gt;

    $('#groupTypes').change(function(){

      var grouptype = $('#groupTypes').val();
      $.post("GroupModificationSuccess.php", {grouptype: grouptype});
    });

  &lt;/script&gt;
</code></pre>
