You can use code generated in other editors including forms, PHP, Java script, etc. if you first go to your Moodle configuration/editor settings and change the htmleditor to "do not allow". Thus, when you edit a page, only the html script editor will open. You can also enter the html editor then toggle the <> script editor, paste your script, then save the file while you are still in the script editor, but if you open the html editor again, your script will be lost.
Paste only the script that is inside the body (do not use the body tags) into the Moodle script editor then save the page. Moodle already has the header and body tags built in.
Your imported script should now work. However if you turn the HTML editor back on and then attempt to edit this page, the Moodle HTML editor will attempt to rewrite your script and it will chew it all up. I keep a backup copy of the script I enter into Moodle in a WordPad file so I can fix it if I forget and mess up the script by entering the html editor.
I think you will want to leave the htmleditor on for general use but you can turn it off to build special pages.
Let me know if this works for you.