Hello all,

I am trying to add the values from a variable number of select drop
downs. I have assigned each select element that I want to add a class
of "weight" to make searching for them easier. The goal is to have all
of the numeric values from each select element with the class "weight"
added together and displayed in an html element with the id
"grand_total"

My code so far:

<script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></
script>
<script type="text/javascript">

                        function weightTotal()
                        {

                                var all = $(".weight");
                                var temp;
                                var obj = jQuery.each(all, function() {
                                        if(this.value != "")
                                        {
                                                temp = temp + 
parseInt(this.value);
                                        }
                                });

                                
document.getElementById("grand_total").innerHTML = temp + "%";

                        }

</script>

So far, the only thing displayed in the "grand_total" element is NaN%

Can anyone help a jQuery newbie out? Thanks in advance.

Reply via email to