...

View Full Version : document.write



rechocto
07-23-2004, 09: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)">
</form>
<br>


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?
:confused:
-Ty,
Rechocto

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

Antoniohawk
07-24-2004, 04: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.)

rechocto
07-24-2004, 05: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.");
a.Close();
)
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:

rechocto
07-24-2004, 06:28 AM
<form name="join" onsubmit="empty()" method="post">
<input type="text" name="user">
desired username
<br>
<input type="password" name="pass">
desired password
<br>
<input type="submit" value="submit">
<br>
<input type="reset" value="reset form">
</form>
<script>
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);
post();
}
}
</script><script>
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);
a.Close();
}
</script>

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

rechocto
07-24-2004, 06: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:...)

kwhubby
07-24-2004, 09: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)

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

kwhubby
07-24-2004, 10: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)

rechocto
07-25-2004, 05: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">
</form>

joinclan.php:

<?php
$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";

srand((double)microtime()*1000000);

$number = rand(100,999);

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

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

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

fclose($fp);

}
?>

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