Fixing the javascript for the dynamic form