如何从提交的do ... while表单中获取值

I have the following code with a form inside a list that should submit the element through Ajax. The values in the form is repeated through a do ... while loop, so that the list become a dynamically list, like in this picture:

SS of the GUI

But when I click a button, the only element that is sent through the Ajax code is the value of the last button, even though I click on Oranges for example.

The code is as follow:

<script>
function submitForm() {
    $.ajax({type:'POST', url: 'jQuery-ajax-demo.php', data:$('#MyJobsForm').serialize(), success: function(response) {
    $('#myJobs_Right').find('.form_result').html(response);
    }});

    return false;
}
</script>

</head>

<body>

<ul id="btn_MyJobs" data-role="listview" data-inset="true">
<li id="MyJobs_List" class="push">
  <form id="MyJobsForm"  onsubmit="return submitForm();">
    <?php do { ?>
      <input type="hidden" name="name" value="<?php echo $row_Recordset1['cargo']; ?>">
      <input type="submit" name="submit" value="<?php echo $row_Recordset1['cargo']; ?>">
      <br/>
      <br/>
      <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
  </form>
</li>
</ul>

<div id="myJobs_Right">
 <div class="form_result"> </div>
</div>

</body>

The jQuery-ajax-demo.php page looks like this:

<?php
if(isset($_POST['name'])) {
    $name = $_POST['name'];

    ?>
    Your Name Is: <?php echo $name; ?><br />
    <?php
    die();
}
?>

If you have to do it this way, then you might try creating a new form for each button:

<?php do { ?>
  <form onsubmit="return submitForm(this);"> <!--Note I added "this" -->
      <input type="hidden" name="name" value="<?php echo $row_Recordset1['cargo']; ?>">
      <input type="submit" name="submit" value="<?php echo $row_Recordset1['cargo']; ?>">
      <br/>
      <br/>
  </form>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

Then the only value that will get posted will be the hidden value that is in the form whose button you clicked. I updated the onsubmit call above to include this in the call. So you can do the below in your function:

function submitForm(form) {
    var $form = $(form);
    $.ajax({
        type:'POST', 
        url: 'jQuery-ajax-demo.php', 
        data:$form.serialize(), 
        success: function(response) {
            $('#myJobs_Right').find('.form_result').html(response);
        }
    });

    return false;
}