Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

textarea question

Status
Not open for further replies.

JerMyster

IS-IT--Management
Mar 17, 2003
49
US
I want to ask a user their name, use their name to load a text file into a textarea (need the scroll bars) on the same page.

I know how to ask the user thier name and then use javascript to load the file into a new page but I don't know how to insert it into a textarea located on the same page.

Thanks.

I just bought some books on HTML and Javascript but very little data on dealing with textareas.

 
If you want to load a text file from the web server then I dont think its possible using javascript alone as this is a client side language and can't access the web server.
I could direct you on how to accomplish this using ASP and VBScript if you wish.

Best wishes


Nick (Webmaster)

info@npfx.com
 
Howard,

VBSCRIPT would be great as I know VB6.

Thanks
 
Hiya

On the first page you would have a form with a text box which posts to the results page. The form would be something like this:

<form action="results.asp" method="post">
<input type="text" name="username">
</form>

Then on results.asp extract the username from the form contents and use the string to open a matching text file from the server:

<%

Dim FSO, f, ts, strText

'Open the filesystemobject

set FSO = Server.CreateObject("scripting.FileSystemObject")

'Open the text file with matching name

set f = fso.GetFile(Server.MapPath("textfiles/" & Request.Form("username") & ".txt")

set ts = f.OpenAsTextStream(ForReading, -2)

'Loop through the stream and build up strText as the contents

Do While not ts.AtEndOfStream
strText = strText & ts.ReadLine & vbCrLf
Loop


'Finally write the contents of strText into the text area
%>

<textarea><%=strText%></textarea>


It would be equally possible to allow the user to amend this text and update it by writing back to the text file. Let me know if you need help on doing this.
Hope this helps!








Nick (Webmaster)

info@npfx.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top