SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Saving as a Text File
-
Aug 28, 2003, 04:05 #1
- Join Date
- Jul 1999
- Location
- Lancashire, UK
- Posts
- 8,277
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Saving as a Text File
Hello
Does anyone know of any way that exsists where i can save a text file from the contents of a form. There is a blog with a database but it would be far superior if i saved the text as an .inc file wich did something like
onSubmit="saveFile()"
function saveFile()
{
txt = txt + a + b + c
save txt
}
Thanks
-
Aug 28, 2003, 05:34 #2
- Join Date
- May 2002
- Location
- Relative
- Posts
- 452
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The FileSystemObject allows the saving and loading of text-files, but unfortunately it will not work client-side due to security restrictions.
However, what you can do is have the form open a new window and write the contents of the form into it, so that you can use the browser File > Save command. But I am a little confused by your question; are you trying to save the contents of a form in one of your own pages, or those of another site?Of course, that's just my opinion. I could be wrong.
-
Aug 28, 2003, 05:53 #3
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
You might also try the saveAs dialog box and an iframe:
Code:<script type="text/javascript"> <!-- function saveIt(formObj) { var txt = ''; for (i = 0; i < formObj.length; i++) { txt += formObj.elements[i].name + ' = ' + formObj.elements[i].value + "<br>"; } theFrame.document.open("text/html","replace") theFrame.document.write(txt) theFrame.document.close() theFrame.focus() theFrame.document.execCommand('SaveAs',true,'myfile.txt') } //--> </script> </head> <body> <iframe id="theFrame" style="display:none"></iframe> <form> <input type='text' name="a"> <textarea name="b"></textarea> <input type='button' value='save it' onclick='saveIt(this.form)'> </form>
VinnyWhere the World Once Stood
the blades of grass
cut me still
-
Aug 28, 2003, 05:57 #4
-
Aug 28, 2003, 06:12 #5
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
save it on a page on my own site
VinnyWhere the World Once Stood
the blades of grass
cut me still
-
Aug 29, 2003, 00:49 #6
- Join Date
- Nov 2001
- Location
- Fife, Scotland
- Posts
- 663
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
why not use inline editing function for IE? So once you have done all your changes you can submit it back to the database, well that's if you use one? Obvioulsy if you wanted it to save as an inc file then your using some sort of scripting language
Bookmarks