...

Writing to a html page.

Mhtml
07-17-2002, 07:04 AM
Ok. I have read a post in this forum already on writing to a html page but I didn't quite understand it. I am learning asp but I'd like a little help on this.

(HERE's THE THREAD I'VE LOOKED @ http://www.codingforums.com/showthread.php?s=&threadid=897&highlight=writing+text+file)


In the post I viewed I saw that you need to open the system file object or something...

<%@Language=VBScript%>
<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
set fs = fso.CreateTextFile("FULL_PATH_TO_YOUR_FILE", true)
fs.write(Request.Form("theText"))
fs.Close
set fs = nothing
set fso = nothing
%>

THAT IS FOR SENDING VIA FORM

But I can't get it to work for my self.

I'll show you my source:

The main page is called appendage.htm:
<html>
<head>

</head>
<body>
<form action="www21.brinkster.com/cubestudios/appender.asp" method="post">
<textarea rows="10" cols="30" name="text1"></textarea>
<br>
<input type="submit">
</form>

</body>
</html>

The .asp page is called appender.asp:
<%@Language=VBScript%>
<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
set fs = fso.CreateTextFile("www21.brinkster.com/cubestudios/appendee.asp", true)
fs.write(Request.Form("form1"))
fs.Close
set fs = nothing
set fso = nothing
%>
<html
<head>
</head>
<body>
</body>
</html>

and the page to be written to is apendee.htm:

<html>
<head>
</head>
<body>

</body>
</html>


That's all the info I think that you will need...Knowing mwe it is probably something extremely simple .lol:D

Thanks in advance..Mike

Morgoth
07-17-2002, 07:43 AM
First off:
fso.CreateTextFile("www21.brinkster.com/cubestudios/appendee.asp", true)

Your creating your ASP page again.

Also, Brinster has a set up that makes DBs be placed only in the DB folder, and I think it allows text files to be made in there too.

Brinkster isn't the best place to do all the coding in the world, that's why I have a webserver on my computer. I can't do many things with brinkster, so maybe your script wont work there if i didn't help you.

Back to the subject:
Edit the code and put this in:
fso.CreateTextFile("www21.brinkster.com/cubestudios/db/appendee.htm", true)

Try it.
Tell us what you got out of it.

<edit>
You might want to also change:
fs.write(Request.Form("form1"))
to
fs.write(Request.Form("text1"))
</edit>

Mhtml
07-17-2002, 07:49 AM
Ok, I tried that but it came up with:

Microsoft VBScript compilation error '800a0414'

Cannot use parentheses when calling a Sub

/cubestudios/appender.asp, line 4

fso.CreateTextFile("www21.brinkster.com/cubestudios/db/appendee.htm", true)
---------------------------------------------------------------------------^

Mhtml
07-17-2002, 09:18 AM
I've installed PWS just then...

Morgoth
07-17-2002, 01:21 PM
Ok...
Hum... I don't really know exactly how that creating text file script works, all I did was try to help out with a few mistakes, and that's what I did, Try to PM the guy that gave out that code, and see what he has to tell you.


Also, remembering when I used Brinkster, I don't think you need the "www21.brinkster.com" in there.
fso.CreateTextFile("/cubestudios/db/appendee.htm", true)

It may not matter if you have done it before.

whammy
07-18-2002, 12:48 AM
I'm not clear from your original post on what you're trying to do... the code you included would create a new file (assuming the path is correct, which doesn't look right - I'd use Server.MapPath if that's what you really want to do), not write to an .asp page.

If you're just trying to pass form variables, use:

<form action="appender.asp" method="post">
<textarea rows="10" cols="30" name="text1"></textarea>
<input type="submit" value="Submit" />
</form>

Then, on "appender.asp" you'd do:

<%
Dim text1 'declare the variable "test"...
text1 = Request.Form("text1")
Response.Write(text1)
%>

To display the value of what you entered in the form of the previous page.

If you'd instead like to save everything to a flat file (for instance a .txt file) and THEN write the results of everything that has ever been saved in that file, check out:

http://www.w3schools.com/asp/asp_ref_filesystem.asp

Instead of CREATING the file every time, you'd want to initially create the file yourself and then add to it using the Scripting.FileSystemObject.

The link above has clear and easy to understand examples. :)

Mhtml
07-18-2002, 04:50 AM
Thanks Whammy...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum