[Javascript] displaying in a textarea field a text file read from the server
Manuel Socarras Reyes
msocarras at terra.es
Sun Mar 3 08:42:45 CST 2002
hi:
O.S.: Windows 2000 Pro
Web server: IIS 5
Browsers: IE 5.0 & NN 6.2.1
i read a text file (created with NotePad) from the server using ASP to
later show its content in a TEXTAREA form field. it works fine as far as
the file doesn't contains car return/line feed chars; if they are
present, this error appears:
Error: unterminated string literal
fileForm.tArea.value = "Testing file read.
txt file
========
Testing file read.
Third line.
ASP page
=======
<%
Const ForReading = 1, ForWriting = 2
Dim fso, f, fContents
Set fso = CreateObject("Scripting.FileSystemObject")
Set f =
fso.OpenTextFile("c:\Inetpub\wwwroot\dwud\filesystemobject\test.txt",
ForReading)
fContents = f.ReadAll
f.Close
%>
<HTML>
<HEAD>
<TITLE>FSO - Read/Write</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<BODY bgcolor="#FFFFFF" text="#000000">
<FORM name="fileForm" method="post" action="">
<P align="center">
<TEXTAREA name="tArea" cols="80" rows="20"></TEXTAREA>
</P>
<P align="center">
<INPUT type="button" name="Button" value="Write">
</P>
</FORM>
<SCRIPT>
fileForm.tArea.value = "<%= fContents %>"
</SCRIPT>
</BODY>
</HTML>
TIA,
--
Saludos,
Manuel Socarrás Reyes <msocarras at terra.es>
Barcelona. Spain
More information about the Javascript
mailing list