hi iDad5, It took a little longer, but it's getting there thanks to your help so far
See https://codepen.io/Vrielsdenies/pen/PoWYpZz
It's working now and then, but not all the time, and I'm not sure if I made a mistake in gsap, or if it's just my mediocre javascript skills ? (or both).
I gave every box data-num attribute, and onDragEnd, I'm looking for the value of this data-num attribute and add or subtract it from the price. This works most of the times, but when you keep dragging the boxes in and out, eventually you'll run into the following error:
pen.js:21 Uncaught TypeError: Cannot read property 'value' of undefined
at Draggable.onDragEnd (pen.js:21)
at Ma (Draggable.min.js:10)
at HTMLDocument.onRelease (Draggable.min.js:10)
So sometimes the value of the attribute is undefined.
Do you perhaps have any idea how I could improve the code so it keeps working?
Many thanks!