Update script.js

redid the submit function for somewhat better readability
probably broke everything, did not test it