Assuming "writeToFile" is written in JavaScript (so you intend it be processed clientside), each form element in your HTML has attributes you can access to get their value. An <input type="text" /> element for example has a "value" property which equals whatever its value is. You can process this value at any time, presuming a suitable event has happened to fire your JavaScript function. lekha phijo gives you one choice, there are a whole bunch available (see
here - being aware some of these will be IE only).
Given the name of your possibly-JavaScript function, I probably should warn you that you cannot write to a file using JavaScript.
If writeToFile is a method written in
Java and to be run serverside, then you just need to process the contents of the request as you would any value passed as the result of a form submission.
[ July 05, 2005: Message edited by: Paul Sturrock ]