I'm new to javascript and jquery. I'm building a shipping calculator that pulls the weights from hidden input fields and adds them together then calculates the shipping price. Due to the proprietary nature of the code I cannot change the code of the input fields. The input fields are named weight1, weight2, etc and the total number of input fields varies depending on the number of items in the shopping cart.
The below code is a mockup webpage meant for designing the script: ------------------------------------------------------------------------------------------------------------------- <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#calculateweight").click(function() { var weightarray = $("input[name*='weight']").val(); }); }); </script> </head> <body> <form> <input type="hidden" name="weight1" value="1.1"> <input type="hidden" name="weight2" value="4.1"> <input type="hidden" name="weight3" value="5.1"> </form> <a href="" id="calculateweight">Calculate Weight</a> <span id="totalweight"></span> </body> </html> ------------------------------------------------------------------------------------------------------------------- When the Calculate Weight link is clicked the script should pull the weights, add them together then do Math.Ceil to round up the result and then pass that to the next part of the script that will compare that weight to a table of weights and prices. My problem currently is that I have no idea how to add together the array of weights to pass them into a variable which I can then run Math.Ceil on. Any help is much appreciated!