Teen Programmer
11-09-2003, 05:53 PM
Is there any way to save a text document using javascript?:confused:
|
Click to See Complete Forum and Search --> : Help!!!!!!!!!!!! Teen Programmer 11-09-2003, 05:53 PM Is there any way to save a text document using javascript?:confused: 96turnerri 11-09-2003, 06:19 PM what you mean save a textbox as a cookie in a txt file or save an actual file onto users computer that can be open and modify on and offline? Teen Programmer 11-09-2003, 06:42 PM Im new to javascript! how do you do that? :o 96turnerri 11-09-2003, 07:03 PM which one? Teen Programmer 11-09-2003, 07:47 PM Sorry, I meant. how do you do the cookie one? :) 96turnerri 11-09-2003, 08:40 PM need to know what you gona save to cookie eg 1 textarea or 2 txtboxes and what are the names? Teen Programmer 11-09-2003, 09:36 PM ;) Type = Textarea Name = mono Charles 11-10-2003, 04:39 AM See http://devedge.netscape.com/library/manuals/2000/javascript/1.3/guide/advtopic.html#1017771. 96turnerri 11-10-2003, 10:50 AM thanks you charles much easier i was gonna type up the code Teen Programmer 11-10-2003, 05:59 PM I am verry sorry but i dont exactly get what there saying on that web page! :( :o :confused: How do i save it? where is the cookie saved? how do i get to it? I am verry sorry! 96turnerri 11-10-2003, 06:12 PM <script type=text/javascript"> function save(text) { var today = new Date(); var expires = new Date(); expires.setTime(today.getTime() + 1000*60*60*24*365) ; setCookie("textbox", name, expires); } </script> <BODY> <SCRIPT type="text/javascript"> var text = getCookie("textbox"); if (yourname != null); document.write(text); } else { document.write("<P>You haven't been here in the last year..."); } </SCRIPT> <form> <INPUT TYPE="button" value="Register" onClick="save(this.form.text.value); history.go(0)"> </FORM> Teen Programmer 11-10-2003, 07:51 PM Thank you for helping me and spending your time! :D :) ;) 96turnerri 11-10-2003, 08:27 PM not a problem let me know the outcome whether it worked or not hope it did lol :D :D :D Teen Programmer 11-10-2003, 10:40 PM Sorry dude, But it didn't work out that well. it got an error Icon at the bottom of the browser and did not do anything! I was wondering if somthing like this would work (it did not work but could you help me correct it?) function save(){ document.cookie = document.myForm.mono.value retrive() } function retrive(){ document.getcookie = document.myForm.mono.value } :) 96turnerri 11-11-2003, 05:53 AM <script type=text/javascript"> function save(text) { var today = new Date(); var expires = new Date(); expires.setTime(today.getTime() + 1000*60*60*24*365) ; setCookie("textbox", text, expires); } </script> <BODY> <SCRIPT type="text/javascript"> var text = getCookie("textbox"); if (yourname != null); document.write(text); } else { document.write("<P>You haven't been here in the last year..."); } </SCRIPT> <form> <INPUT TYPE="button" value="Register" onClick="save(this.form.text.value); history.go(0)"> </FORM> try this if not well work on your script Javium 11-11-2003, 09:06 AM I was interested by this posting, and I tried the below (modified and completed) code. Normally, when clicking on the "Register" button the name entered should be saved in the cookie "textbox" and then, because of history.go(0) it would re-run again, displaying the registered name and date. But it doesn't work. What is missing in this code? Thanks! <html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 1</title> <script type="text/javascript"> function save(text) { var today = new Date(); var expires = new Date(); expires.setTime(today.getTime() + 1000*60*60*24*365); setCookie("textbox", text, expires); } </script> </head> <body> <script type="text/javascript"> var text = getCookie("textbox") if (text != null); { document.write(text); } else { document.write(<p>You haven't been here in the last year..."); } </script> <form name="regin"> <input size=35 name="inputname" value="Javium"> <input type="button" value="Register" onClick="save("this.form.inputname.value"); history.go(0)"> </form> </body> </html> Teen Programmer 11-11-2003, 03:38 PM Your programm did not work! could you help me correct mine thanks! :) Teen Programmer 11-12-2003, 02:05 PM Here is my full prog. I am attemting to make a chat programm. i need to save whatever has been typed in. right when they submit it it is a notepad file. :) 96turnerri 11-12-2003, 05:47 PM a chat program made with javascript is that possible? :eek: Teen Programmer 11-12-2003, 08:45 PM I am not sure! But i am almost sure it will work! I need to save what has been writen to the text area so when you chat every thing that has been posted will be there! I probably dont make sense! sorry if you cant usnderstand! :D but i am sure it will work! :D :) :D 96turnerri 11-12-2003, 08:48 PM well no sry i might be wrong but if you want to save everything that been said in the textarea, then yes you need to get cookies, but how do you propose getting messages from one chatter to another and displayed in the textarea? pyro 11-12-2003, 08:50 PM No, a chat program with JavaScript is not possible. Sorry. It will require some sort of server-side language, and would best be done in Java. Teen Programmer 11-12-2003, 08:53 PM You would need to save the textarea to a cookie. and then retrive it on clicking the send! you can retrive cookies cant you? :D :o Teen Programmer 11-12-2003, 09:12 PM I am still gona try! ;) pyro 11-12-2003, 09:14 PM You can try all you want, but how are you going to save the information to a file, and how are you going to read from that file so other users can view what you have typed? Good luck - you're going to need it... Teen Programmer 11-12-2003, 09:18 PM Cant you save info to a cookie? And retrive it? :) pyro 11-12-2003, 09:38 PM Yes you can. Can other people read the contents of your cookies? No they can't. Teen Programmer 11-12-2003, 11:07 PM okay! i guess it does seem impossible! :D :) ;) :D 96turnerri 11-13-2003, 05:11 AM ok nice thought tho, can sorta see where your coming from and why you thought it might of worked Javium 11-13-2003, 03:24 PM Hello Teen Programmer I cannot help you solving your chat problem, but I have found an javascipt that can hopefully help you at http://javascript.internet.com/messages/textchat-v1.2.html Javium 96turnerri 11-14-2003, 07:24 AM i cannot see that working either to be honest webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |