javascript to handle "add" button