Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post

    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 @ write to page permantately)


    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

  • #2
    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
    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>

  • #3
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    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)
    ---------------------------------------------------------------------------^

  • #4
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    I've installed PWS just then...
    Omnis mico antequam dominus Spookster!

  • #5
    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
    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.

  • #6
    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
    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.
    Last edited by whammy; 07-18-2002 at 12:53 AM.
    Former ASP Forum Moderator - I'm back!

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

  • #7
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Thanks Whammy...
    Omnis mico antequam dominus Spookster!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •