Don't get hung up on the id tag, that was just an easy way to get a reference to the element in question.
What would be the easiest way then, to pass the totalCost variable to the PHP script?
Would something like this do it?
Note the absence of an id tag on the hidden field.HTML Code:
<form action="myscript.php" method="post">
... All of your form stuff ...
<input type="hidden" name="total">
<input type="submit" value="Submit">