How to create entry in other forms using custom script

The idea is in form1 there are field A and B in form2 there are fields C and D.

So whenever form1 is saved I want the data from field A and B to be saved in form2 in field C and D.
How can this be achieved using custom scripts ?