Hello everyone!
I have made two div boxes that can move html table lines from one to other and back!
So far everything works good!
But now in column “amount” in some cases i do not need to move all of it so i added inputs for each line.
I can move it to other div with that amount but i want to be able to move it back (or part of it) and add it to line i took it from
If I understand the problem correctly, when you click the icon to transfer some items “back” from storage 2 to storage 1, the problem is that instead of just moving the amounts, it adds a new (duplicate) row in storage 1.
If that’s the case, you need to add some code to first check whether the code you’re moving “back” from storage 2 to storage 1 already exists. At the moment, it appears that when you click the icon in storage two, one of the first things you do is append a copy of the row onto storage one. Before that, you need to see whether there’s already a row for that code, and if there is, only alter the amount.
I’d think you would need to do the same when moving in the other direction, too, unless the two locations will never have the same codes at the start.
So the pseudo-code is something like
get the details of the row to copy
look down the destination table for that code
if it's there:
adjust the amounts to suit
if it's not:
append the row as you are doing now