$(document).ready(function(){


    $('#orderForm input, #orderForm textarea').click(function(){
            if(this.value == this.title)
                this.value = '';
    });

    $('#orderForm input, #orderForm textarea').blur(function(){
            if(this.value == '')
                this.value = this.title;
    });

    var order = [], i = 1;
    $('#but_plus').click(function(){
            var val = document.getElementById('product').value; // селект

            var container = document.getElementById('results_order');
            var block = document.createElement('DIV');

            var name = document.createElement('DIV');
            name.className = 'nameOrd';
            name.appendChild(document.createTextNode(val));

            var minus = document.createElement('DIV');
            minus.className = 'but_minus';
            minus.title = 'Удалить позицию';
            minus.id = 'minus_'+i;

            order['minus_'+i] = val;

            minus.onclick = function(){

                var ind = this.id;
                this.parentNode.style.display = 'none';

                delete order[ind];

                var hidInpVal = '';
                for(var n in order)
                    hidInpVal += order[n] + ' | ';

                    document.getElementById('prod').value = hidInpVal;
                    console.log(document.getElementById('prod').value);
            }

            block.appendChild(name);
            block.appendChild(minus);
            container.appendChild(block);

            var hidInpVal = '';
            for(var n in order)
                hidInpVal += order[n] + ' | ';

                document.getElementById('prod').value = hidInpVal;
            
            i++;

            console.log(document.getElementById('prod').value);
    });
});


