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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write a text area to a file

Status
Not open for further replies.

caconner

Technical User
May 20, 2002
42
US
Ok, this should be a simple question for anyone other than a beginner like me...

I'm trying to write the contents of a textarea to a file. I have the code to write to the file, I just can't figure out how to pass the content/value of the text area to a variable, then to the file on a button click. My knowledge of forms is extremely limited, so I'm not sure what method and/or action to use in conjunction with this.

TIA.

<form action=&quot;&quot; method=&quot;post&quot; name=&quot;UpdateACOE&quot;>

<textarea name=&quot;txtUpdateACOE&quot; cols=&quot;60&quot; rows=&quot;20&quot;></textarea>

<input name=&quot;save&quot; type=&quot;button&quot; id =&quot;save&quot; value=&quot;Save&quot;>

sub save_onclick
dim Str
Str = request(&quot;txtUpdateACOE&quot;)

dim objFSO
set objFSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
if objFSO.FileExists (&quot;acoe.txt&quot;) then
dim objTextStream
set objTextStream = objFSO.OpenTextFile (&quot;acoe.txt&quot;, 2)
objTextStream.write str
objTextStream.Close
set objTextStream = Nothing
Set objFSO = Nothing
end if
end sub
</script>
</form>


 
<input name=&quot;save&quot; type=&quot;button&quot; id =&quot;save&quot; value=&quot;Save&quot;>

change that to:

<input name=&quot;save&quot; type=&quot;[red]submit[/red]&quot; id =&quot;save&quot; value=&quot;Save&quot;>


-pete
 
the way you had it written was to run client side which you cant do with fso, modify the code as palbano suggested and make the code run server side.
 
of course this will require changing out sub_onclick etc, ( well technically since asp doesn't quite recognise 'onclick' ) you can leave the name alone, but for the sake of confusion you should rename it to exporttext or something

also remove the script tags and replace them with <% and %> and convert the code more
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top