$(function(){ // Name the datagrid function to create a table - flexigrid $('#cartcontent').datagrid({ singleSelect:true, showFooter:true }); // Specifying whether the item is draggable $('.item').draggable({ revert:true, proxy:'clone', onStartDrag:function(){ $(this).draggable('options').cursor = 'not-allowed'; $(this).draggable('proxy').css('z-index',10); }, onStopDrag:function(){ $(this).draggable('options').cursor='move'; } }); // Drop in cart section $('.cart').droppable({ onDragEnter:function(e,source){ $(source).draggable('options').cursor='auto'; }, onDragLeave:function(e,source){ $(source).draggable('options').cursor='not-allowed'; }, onDrop:function(e,source){ var name = $(source).find('p:eq(0)').html(); var price = $(source).find('p:eq(1)').html(); addProduct(name, parseFloat(price.split('£')[1])); } }); }); // Adding a new row for new products function addProduct(name,price){ var dg = $('#cartcontent'); var data = dg.datagrid('getData'); function add(){ for(var i=0; i