I would imagine that this second code snippet (save_click) is attached to a SAVE button on the second form ? Could you not just fill in the data, then attach to the save button in script, then invoke its click method which would then invoke this entire event for you ... ?