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 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2003
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form Textfield to modify a file?

    Howdy,

    I'm trying to find a way that a User can go to a specific website that would allow them to enter some text that would then be shown on the primary website.

    I thought I could have a form with just a textarea box. Then whatever they entered could be sent to a TXT or HTML file which could be Included onto the primary page.

    How wouls I go about doing this so that any time the form is used, it would overwrite anything that was in the file before. Or ever better, when they go to the form it would read whatever was in the file into the box, and then let them edit it or change it all, and then re-write it back to the file.

    Is this doable in ASP or is there a better way to do this?

    Any input is much appreciated.

    THanks,
    --Mike

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Well, here some useful links you might want to read.

    Opening text files:
    http://www.devguru.com/Technologies/...ntextfile.html

    Creating text files:
    http://www.devguru.com/Technologies/...etextfile.html

    Other methods and properties of the FileSystemObject:
    http://www.devguru.com/Technologies/...temobject.html

  • #3
    New Coder
    Join Date
    Jan 2003
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is the text from the first link you posted:

    PHP Code:
    <%
    dim filesysfiletxt
    Const ForReading 1ForWriting 2ForAppending 
    Set filesys 
    CreateObject("Scripting.FileSystemObject")
    Set filetxt filesys.OpenTextFile("c:\somefile.txt"ForAppendingTrue
    filetxt.WriteLine("Your text goes here.")
    filetxt.Close 
    %> 
    Which part of that does the actual writing to the file? And, how can I edit it to make it pull the text to write from a form field?

    I'm assuming I do it like this...

    1) Use the script above (or part of it) to open the file and read in the current file's contents into a TextArea into a form.
    2) Allow user to modify what's in the TextArea window
    3) Set up a button so when they click it, it would write the new contents of the TextArea window to the file and OverWrite whatever might have been in there before.

    But, I know next to nothing about ASP so if someone could explain it in a bit more detail for me, that'd be great!

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    But, I know next to nothing about ASP so if someone could explain it in a bit more detail for me, that'd be great!
    I think you should learn about ASP and VBScript first.
    http://www.w3schools.com/asp/default.asp
    http://www.w3schools.com/vbscript/default.asp

  • #5
    New Coder
    Join Date
    Jan 2003
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Learn the whole language just to do this one tiny script? I'd love to but I'd rather have this working ASAP and then learn how and why it works and go from there.


  •  

    Posting Permissions

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