You actually want to use arrays for these. You can name them if you want, but if the name's have no actual value by themselves, than a list is what you'll get.
PHP retrieves arrays from html with the following conventions:
<input type="text" name="yourname[specificoffset]" /> where you can now find the value in $_POST['yourname']['specificoffset']. If no specific is required, than a simple [] will suffice. 'yourname' is whatever you want to call it.
Then in processing you simply sum them up:
PHP Code:
if (isset($_POST['yourname']))
{
$total = array_sum($_POST['yourname']);
}
Or iteratively with a for or foreach loop.
Naming them is useful if you want to display some info for them. You can retrieve that from the key() of the array during iteration, or $key from the foreach:
PHP Code:
foreach ($_POST['yourname'] AS $k => $v)
{
printf('Value for %s is %s' . PHP_EOL, $k, $v);
}
Like that.
This works well with JS as well as you can create the item with the same naming convention and append it to the dom forms.