I've got two tables. Left side containing all items, right side showing the ordered items. (See picture) [![enter image description here](https://i.stack.imgur.com/3ZTWm.png)](https://i.stack.imgur.com/3ZTWm.png)

What I want to do: 
If an item from the left table is already added on the right table, instead of adding it again, just increase the quantity by one instead. If that's not the case, just add it.. 

Code:
**HTML**

```
<form id="OrderedItemsWithoutBatch" class="orderedDataWithoutBatch">
<table class="orderFormArticlesTable" style="width: 47%;float: right; font-size: 9pt;">
    <thead>
        <tr>
            <th>SKU</th>
            <th>Product</th>
            <th style="width: 15%">Qty</th>
            <th></th>
        </tr>
    </thead>
    <tbody id="orderedItemsVM" data-bind="foreach: orderedItems">
        <tr class="clickable" data-bind="css: { alternate: $index()%2 }">
            <td data-bind="text: MateriaalSku"> </td>
            <td data-bind="text: MateriaalDescription"> </td>
            @*<td class="onelineData"><input style="width:2em" type="text" /> [pieces] </td>*@
            <td><input class="orderedQty" style="max-width: 15%" data-bind="value: materiaalAantal"/>[pieces]</td>
            <td data-bind="click: function() { $parent.orderedItems.remove($data); }"><a href="#">Remove</a></td>
        </tr>
    </tbody>
</table>

```

**JS**

```
$(document).ready(function () {
var dataTableForm = $("form.dataWithoutBatch");
var orderedItemsTable = $("form.orderedDataWithoutBatch");
var dataReloading = false;
var currentPage = 0;

//viewModel
var viewModel = {
    orderedItems: ko.observableArray(),
    items: ko.observableArray(),
    sortColumn: ko.observable(),
    total: ko.observable()
}

var request = $.post(url, postData);
    request.fail(function () {
        alert('Failed!');
    });
    request.always(function () {
        listItemsParameterInputs.prop('disabled', false);
        $(document.body).removeClass("loading");

        dataReloading = false;

        if (callback) {
            callback();
        }
    });
    request.done(function (data) {
        viewModel.total(data.Total);
        viewModel.items.removeAll();

        for (var index = 0; index < data.Items.length; index++) {
            var item = data.Items[index];

            if (item.hasOwnProperty("qty")) {
                item.qty = ko.observable(item.qty);
            }
            else {
                item.qty = ko.observable("");
            }
            item.addItem = function () {
                //Check if item is already in the table on the right
                if(viewModel.orderedItems.indexOf(this) < 0){
                    viewModel.orderedItems.push(this);

                }
                else{
                    // Increase quantity by one.
               }
            }
            viewModel.items.push(item);
        }

```