First, don’t change erpnext or frappe documents. There are several way to do the customization, just check the manual.
Second, in my opinion the best way is to make your own app and put your js code inside public folder of your module and mention it in web_include_js or app_include_js in hook.py file.
Or put your code inside setup/Custom Script.
I don’t know if i understand you but if you need to have a custom web form instead of the real doctype form and fill it with data of the custom web form what you must to do is gather all the web form data send it to server (for security reasons…), validate and from your module create a new doc (doc = frappe.new_doc(…)) fill it with your data and save it to database (doc.save()).
To make a custom page you must check the documentation.