Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-17-2002, 07:04 AM   PM User | #1
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
Writing to a html page.

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/showthre...ting+text+file)


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

Code:
<%@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:
Code:
<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:
Code:
<%@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:
Code:
<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

Thanks in advance..Mike
Mhtml is offline   Reply With Quote
Old 07-17-2002, 07:43 AM   PM User | #2
Morgoth
Senior Coder

 
Morgoth's Avatar
 
Join Date: Jun 2002
Location: Ontario, Canada Remaining Brain Cells: 6
Posts: 1,402
Thanks: 2
Thanked 1 Time in 1 Post
Morgoth is an unknown quantity at this point
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>

Last edited by Morgoth; 07-17-2002 at 07:47 AM..
Morgoth is offline   Reply With Quote
Old 07-17-2002, 07:49 AM   PM User | #3
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
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 is offline   Reply With Quote
Old 07-17-2002, 09:18 AM   PM User | #4
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
I've installed PWS just then...
__________________
Omnis mico antequam dominus Spookster!
Mhtml is offline   Reply With Quote
Old 07-17-2002, 01:21 PM   PM User | #5
Morgoth
Senior Coder

 
Morgoth's Avatar
 
Join Date: Jun 2002
Location: Ontario, Canada Remaining Brain Cells: 6
Posts: 1,402
Thanks: 2
Thanked 1 Time in 1 Post
Morgoth is an unknown quantity at this point
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.
Morgoth is offline   Reply With Quote
Old 07-18-2002, 12:48 AM   PM User | #6
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
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.
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)

Last edited by whammy; 07-18-2002 at 12:53 AM..
whammy is offline   Reply With Quote
Old 07-18-2002, 04:50 AM   PM User | #7
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
Thanks Whammy...
__________________
Omnis mico antequam dominus Spookster!
Mhtml is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:23 PM.


Advertisement
Log in to turn off these ads.