Create comma separated value from multiple fields
<p>I have between 1-10 form fields posted to a php script that collects the values from existing fields and use that data</p>

<p>Since I am trying to change some functions on the site to ajax I wonder how I can, with jquery, find all the fields with the name <code>amount-*</code>and put their values in a comma separated string and then post it to the server side script via ajax like this:</p>

<p><em>New code</em></p>

<pre><code>$("#div").load("/serverscript.php", {ids:commaSeparatedValues}
</code></pre>

<p><em>Old code</em>    </p>

<pre><code>while(isset($_POST['amount-'.$indexCount])){
  $changedCartAmount = $changedCartAmount . $_POST['amount-'.$indexCount] . ',';
  $indexCount++;
}
$changedCartAmount = substr($changedCartAmount,0,-1);
$arrayChangedCartAmount = explode(",",$changedCartAmount);
</code></pre>
