Im totally new to ASP so any help would be very grateful. I have a html page which has a form for users to leave their details and when they submit it goes to a text file fine but what I want is once they have submitted it I want to have an alert saying "comment saved" and to stay on the original page so they can submit another if they choose but when the user submits it goes to a blank page. My Form is
<form method="post" action="comments.asp">
<br><br>
Age <input type="text" name="age" />
Name<textarea rows="1" cols="70" <input type="text" name="name" /></textarea>
<input type="submit" value="Send Comment">
</form>
my comments.asp file code is
<%
Dim age, name
age = Request.Form("age")
name = Request.Form("name")
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile("C:\Inetpub\wwwroot\Wiki\Comments.txt",8,true)
f.WriteLine(age & " " & date() & " " & name)
f.Close
set f=nothing
set fs=nothing
%>
<%
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
'Open the file for writing
Set f = fso.CreateTextFile(s_path & "/" & s_file_being_created, True)
f.Write(m)
f.Close
Set f = Nothing
Set fso = Nothing
%>
For those of you writing ASP with JScript instead of VBS, the code might look something like this:
var fileSystemObject = Server.CreateObject("Scripting.FileSystemObject");
var textStream = fileSystemObject.CreateTextFile(filePath, true, true);
textStream.Write(fileContent);
textStream.Close();
delete textStream;
delete fileSystemObject;
Documentation references:
Scripting.FileSystemObject
objectFileSystemObject.CreateTextFile()
methodTextStream
objectWrite()
methodClose()
methoddelete
operatorIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With