A server-side JavaScript can dynamically build in the HTML code for a form element


A server-side JavaScript can dynamically build in the HTML code for a form element that is part of the page. As an example, you can have the following statement in a source document:

<INPUT TYPE=”text” NAME=”example” VALUE=’request.agent’>

In this case the default value of the text is the browser agent information.

You use an identical procedure for hidden form elements


You use an identical procedure for hidden form elements. The only difference is that the type is hidden instead of text.
client-side JavaScript can then use this value as part of any function.

By changing the part of the JavaScript code


By changing the part of the JavaScript code you can make your pages come alive.
When you send a page to the browser it can contain JavaScript code for the browser to execute as part of the page. There is no reason that this code has to be static.

In building a non-trivial application, you need to


In building a non-trivial application, you need to be able to read and write data from a file.
It can be customer information, data about merchandise, or student grades. This is a basic procedure in almost every application.

LiveWire provides a file object which allows your application


LiveWire provides a file object which allows your application to write to the server’s file system.
As a security measure, JavaScript on the browser does not permit saving data to the file system.

Like other JavaScript operations


Like other JavaScript operations, file handling is also done using objects.
LiveWire provides a file object and you create new objects for each file you want to use. If you need to use file files, then create a new file object for each one.

After you create the file object, you then need to open the file


After you create the file object, you then need to open the file before you can do anything else with it.
To open the file, you use the open method, as follows:

result=fileObjectName.open (“mode”)

The result is true if the file was opened successfully; otherwise it is false.

When dealing with data stored in a file


When dealing with data stored in a file, you must consider where in the file the desired data is stored or where you intend to store it. You may not want to read the first three items, but you do want to read the next two items.
The file object allows you to read the current position, change the position, or check if you are at the end of the file.

When you open a file, the current position depends on the mode


When you open a file, the current position depends on the mode you use to open it.
Generally it starts at the beginning of a file, except for modes a+ and a where data is appended at the end of an existing file. For empty or new files, the end of the file and the beginning of the file are the same.

In reading a file you often want to read through the entire thing


In reading a file you often want to read through the entire thing, but to do so you need to know when you have reached the end.
So you test for the end of the file (eof). The file object has the eof method that returns a true after the first read operation that attempts to read past the end of the file.