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 10 of 10

Thread: document.write

  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question document.write

    Code:
    <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?

    -Ty,
    Rechocto

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Not a chance with javascript. You need a serverside language to do this

  • #3
    Senior Coder
    Join Date
    Aug 2002
    Location
    Kansas City, Kansas
    Posts
    1,518
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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].

    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.)

  • #4
    New Coder
    Join Date
    May 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    that actually works VERY well, but when its used, norton considers it a malacious code..(
    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.

  • #5
    New Coder
    Join Date
    May 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    Code:
    <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..

  • #6
    New Coder
    Join Date
    May 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:...)

  • #7
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    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)
    Last edited by kwhubby; 07-24-2004 at 09:47 AM.
    Kris Hubby
    kwhubby site

  • #8
    New Coder
    Join Date
    May 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    yah im using 1&1, thanks for the help, ill look into that

  • #9
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    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)
    Kris Hubby
    kwhubby site

  • #10
    New Coder
    Join Date
    May 2004
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    heh, yall can close the disc if u want
    join page:
    Code:
    <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:
    Code:
    <?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...


  •  

    Posting Permissions

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