[Javascript] displaying in a textarea field a text file read from the server

TomMallard mallard at serv.net
Sun Mar 3 09:00:48 CST 2002


Try replacing the carriage return in vbscript on the server...

strText = replace(strText, vbcrlf, "<br>")

This may do the job.

tom mallard
seattle
-----Original Message-----
From: javascript-admin at LaTech.edu [mailto:javascript-admin at LaTech.edu]On
Behalf Of Manuel Socarras Reyes
Sent: Sunday, March 03, 2002 6:43 AM
To: javascript at LaTech.edu
Subject: [Javascript] displaying in a textarea field a text file read
from the server


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




_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list