Well first off I don't see anywhere in this code where you are loading the body of every single text/xml file in your directory into a javascript array. Are you doing that somewhere?
You problem is that you aren't thinking about PHP being a server side language and the Web being a stateless environment. Once your page with it's dropdown list is generated and displayed on the users machine there is no more interaction with the server until the user clicks another link or submits a form.
To fix your problem you need to have this page be 2 forms. The first form encompases just your dropdown list and get's submitted back to itself. The second form is only displayed if the first form has been submitted and then it displays the text of the selected file in your textarea and allows your users to edit and save that data.