Moving values between div boxes

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

Here are an half working example https://jsfiddle.net/8L9zu4qg/1/

Example of what i need to achieve:
There is 7 1CODE in storage 1 and 0 1CODE in storage 2
now i m moving 3 1CODE from storage 1 to storage 2

so there is now 4 1CODE in storage 1 and 3 1CODE in storage 2

now lets say i made mistake and i needed to move only 2 so i need to move 1 back
to make 1CODE 5 in storage 1 and 1CODE 2 in storage 2

I hope i explained well :dizzy_face:

color meaning:
silver: moved without value change
green: value that moved from other box
red: value left from moving

Thanks

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
1 Like

Tying to do so! Cant get matching line

half way done

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.