This is my code:

```
 $(document).ready(function () {
        $("#afiseaza_subtotal").click(function(){
            var i = 0; var list = []; 
            $(".name1").each(function(){
                list[i] =  $(this).val();
                i++;
            });
            var uniqueNames = [];
            $.each(list, function(i, el){
                if (el !=""){
                    if($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
                }
            });
            var html = "";
            if (uniqueNames.length > 0){
                $.each(uniqueNames, function(i, value){
                    var sum = 0;
                    if ($(".name1").attr("value") == value ){
                       // sum = parseFloat($(this).parent(".prod-persoana1").prev(".prod-pret1").find(".price").text());
                    }
                    //

                    html += "<p>Subtotal "+value+"-"+ sum +" lei </p>";

                });
                // initial_html = $(".subtotal").html();
                $(".subtotal").append(html);
            }else{
                alert("dasdasd");
            }
        });

    });

```

In the array uniqueNames i have all of the DISTINCT inputs value. I also another item where it is the sum. I want to get all of the **sum** value from the same **input**. See the example below:

```
 12$    Name1
 13.4$  Name2
 14$    Name1
 14$    Name3

```

the result will be a subtotal, which will look like this:

```
26$    Name1
13.4$  Name2
14$    Name3

```

As I said in the array uniuqNames I got the unique Names. Now I need to get the sum . How do I get the sum ?

This is the html code:

```
<div class="prod-pret1">
    <span class="price bolder">6.8 </span> Lei
</div>
<div class="prod-persoana1">
    <input name="nume1" type="text" id="nume1" class ="name1" value="" placeholder="Nume">
</div>
<div class="prod-pret1">
    <span class="price bolder">6.8 </span> Lei
</div>
<div class="prod-persoana1">
    <input name="nume2" type="text" id="nume2" class ="name1" value="" placeholder="Nume">
</div>
.....

```