View Full Version : document.write

07-23-2004, 10:15 PM
<form name="test" method="post" action="test.txt">
<input type="text" name="testt"><br>
<input type="submit" value="submit" onclick="document.write(document.test.testt.value)">

what I'm trying to do is to get it to write the contense of the textbox onto test.txt, but all it does is change ur temporary file's source for the page your on to ONLY contain what was in the text box, and it doesnt even save anyways. is there any way I can make it write onto test.txt and save it?

07-23-2004, 10:17 PM
Not a chance with javascript. You need a serverside language to do this

07-24-2004, 05:08 AM
I think what Nightfire meant was that it is possible to do this in javascript, but but the language is so unsuited for such operations that it might as well not have the capability. An IE only javascript method of this can be achieved using [FileSystemObject (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/jsobjFileSystem.asp)].

Try your hand at that, and if you come across any problems, search the the javascript forum and then resort to asking. :)

(No hard feelings Nightfire, php is a much more viable solution for this.)

07-24-2004, 06:29 AM
that actually works VERY well, but when its used, norton considers it a malacious code..(

var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile("testfile.txt", true);
a.WriteLine("This is a test.");
but, IT does work, whats norton's problem with writing a text file? thats no more dangerious than a cookie that remembers your username and password so u dont ahve to log into a site over and over. :thumbsup: :cool: :confused:

07-24-2004, 07:28 AM
<form name="join" onsubmit="empty()" method="post">
<input type="text" name="user">
desired username
<input type="password" name="pass">
desired password
<input type="submit" value="submit">
<input type="reset" value="reset form">
function empty() {
if (document.join.user.value==''){
alert('pick a username');
if (document.join.pass.value=='') {
alert('whats your password going to be?')
else {
alert('your username will be:\n' + document.join.user.value);
alert('your password will be:\n' + document.join.pass.value);
function post() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile(document.join.user.value + ".txt", true);
a.WriteLine("user: " + document.join.user.value);
a.writeline("pass: " + document.join.pass.value);

thats exactly like i want, but for some reason, (like i said before), norton antivirus considers it malacious code..

07-24-2004, 07:47 AM
wait, it might just be the fact that tis saving the text file TO my computer from the page.. anyone know a way to make it write onto my webspace?
(it's for my Runescape (an interactive rpg on the net) Clan, the Rskia ( http://rskia.com ) so its easier for me to get them in and joined than my old email script (<form action="mailto:...)

07-24-2004, 10:42 AM
Javascript will not work for this since it works only on the client side (unless your using server side javascript with asp) and has no ability to do anything of that nature to the host. You will need to use a server side language such as php to handle a form that u submit to the server which would then write this to a text file or database, etc. You would need to check with your host to see if they have support for any server side languages (doing a whois on ur site looks like ur using 1&1 which supports various server side languages)

07-24-2004, 11:20 AM
yah im using 1&1, thanks for the help, ill look into that :D

07-24-2004, 11:58 AM
A request for what you want would be best suited for one of the server side development forums (I would personally recomend going the php route for this)

07-25-2004, 06:40 AM
heh, yall can close the disc if u want :D
join page:

<form name="join" action="joinclan.php" method="POST">
<input type="text" name="user"> desired username<br>
<input type="password" name="pass"> desired password<br>
<input type="password" name="pass2"> retype password<br>
<input type="text" name="rsuser"> runescape username<br>
<input type="submit" value="submit">
<input type="reset" value="reset">


$user = $_POST["user"];
$rsuser = $_POST["rsuser"];
$pass = $_POST["pass"];
$pass2 = $_POST["pass2"];

if ($user == "") { echo "Please pick a username.<br><br><a href=join.html>Back</a>";

} elseif ($pass == "") { echo "Please pick a password.<br><br><a href=join.html>Back</a>";

} elseif ($pass2 == "") { echo "Please verify your password.<br><br><a href=join.html>Back</a>";

} elseif ($pass != $pass2) { echo "The passwords you entered do not match.<br><br><a href=join.html>Back</a>";

} elseif ($rsuser == "") { echo "Please state your RuneScape username.<br><br><a href=join.html>Back</a>";

} else {

echo "Your username will be: $user<br>Your password will be: $pass<br>Your RuneScape name is: $rsuser";


$number = rand(100,999);

$filename = "$user($number).txt";

$fp = fopen($filename, "a");

fwrite($fp, "user: $user
pass: $pass
rs-user: $rsuser");



after a lot of work i finally got a webserver to support ftp on ym comp and on my site i used an iframe to http://<my ip address>/join.html and it all works fine now :) thanks for all your help!

p.s. wow, php is an easy language...

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum