Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9266485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:19:47+00:00 2026-06-18T14:19:47+00:00

I am trying to write to a file from an html form, however the

  • 0

I am trying to write to a file from an html form, however the write part of the javascript doesn’t do anything.

Only the validate part of the script seems to be working.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<script LANGUAGE="JavaScript">
function Write(input1, input2)
{
    var fso =  new ActiveXObject("Scripting.FileSystemObject");  
    var s = fso.OpenTextFile("C:\\test.txt", true);
    s.WriteLine(input1 + "," + input2);
    s.Close();
}

function validateForm() {
    var x1=document.userform.pwd.value;
    var x2=document.userform.re_pwd.value;
    if (x2 == x1){
        Write(document.userform.user.value, document.userform.pwd.value);
    }
    else{alert("Passwords are not the same, Re-enter password");}
}
</SCRIPT>

<head>

    <link rel="stylesheet" href="css/screen.css" media="screen" />
</head>
<body>

<div id="container">

        <h2>Create a new account <?php echo "It works!"; ?></h2>
        <form id="form1" NAME="userform" METHOD="GET" ONSUBMIT="return validateForm()" ACTION="">   

            <fieldset><legend>Create a new Account</legend>
                <p class="first">
                    <label for="username">Username</label>
                    <input type="text" name="user" size="30" />
                </p>
                <p>
                    <label for="password">Password</label>
                    <input type="password" name="pwd" size="30" />
                </p>
                <p>
                    <label for="repassword">Re-enter Password</label>
                    <input type="password" name="re_pwd" size="30" />
                </p>

            </fieldset>             

            <p class="submit"><button type="submit" value="Submit">Signup</button></p>          

        </form> 

</div>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:19:49+00:00Added an answer on June 18, 2026 at 2:19 pm

    I pulled out my general .HTA read/write routines and dropped them in here for you.

    • Removed the XHTML stuff and switched to the HTML 5 doctype
    • Cleaned up markup to be HTML5 compliant.
    • Fixed the ID‘s in your INPUTS. The label element matches by ID, not name.
    • Added a return false to your form.

    General notes:

    • Only constructors should start with a capital letter.
    • This must be saved with a .HTA file name
    • Needless to say, this is windows only.

    <!doctype html>
    <html>
    
    <script>
    
    var ie_writeFile = function (fname, data) {
        var fso, fileHandle;
        fso = new ActiveXObject("Scripting.FileSystemObject");
        fileHandle = fso.CreateTextFile(fname, true);
        fileHandle.write(data);
        fileHandle.close();
      };
    
    var ie_readFile = function (fname) {
        try {
          fso = new ActiveXObject("Scripting.FileSystemObject");
          var fso, filehandle, contents;
          filehandle = fso.OpenTextFile(fname, 1);
          contents = filehandle.ReadAll();
          filehandle.Close();
          return contents;
        } catch (err) {
          return null;
        }
      };
    
    
    
    function Write(input1, input2)
    {
        var s = input1 + "," + input2;
        ie_writeFile("test.txt", s);
    }
    
    function validateForm() {
        var x1=document.userform.pwd.value;
        var x2=document.userform.re_pwd.value;
        if (x2 == x1){
            Write(document.userform.user.value, document.userform.pwd.value);
        }
        else{alert("Passwords are not the same, Re-enter password");}
    }
    </script>
    
    <head>
    
        <link rel="stylesheet" href="css/screen.css" media="screen">
    </head>
    <body>
    
    <div id="container">
    
            <h2>Create a new account <?php echo "It works!"; ?></h2>
    
    
            <!-- return false added to keep the form from reloading -->
    
            <form id="form1" NAME="userform" METHOD="GET" ONSUBMIT="return validateForm();return false" ACTION="">   
    
                <fieldset><legend>Create a new Account</legend>
                    <p class="first">
                        <label for="username">Username</label>
                        <input type="text" name="user" id="user" size="30">
                    </p>
                    <p>
                        <label for="pwd">Password</label>
                        <input type="password" name="pwd" id="pwd" size="30" />
                    </p>
                    <p>
                        <label for="repassword">Re-enter Password</label>
                        <input type="password" name="repassword" id="repassword" size="30" />
                    </p>
    
                </fieldset>             
    
                <p class="submit"><button type="submit" value="Submit">Signup</button></p>          
    
            </form> 
    
    </div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to upload a zip file and a csv file from HTML form.
I'm trying to write a script that will search through a html file and
I'm trying to write a code to extract some form data from a HTML
I'm trying to write a file from an Http post reply to a file
I am trying to write a txt file from C# as follows: File.WriteAllText(important.txt, Convert.ToString(c));
I'm trying to find a way to write to a text file from as2.
I am trying to write my spatial data from a table to a file.
I'm trying to adapt a code to extract information from wunderground. However the script
Right now I'm trying to write a script that will only accept certain audio
I'm trying to write an html/javascript set (to be interpreted in PHP) that allows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.