www.webdeveloper.com
Results 1 to 9 of 9

Thread: Send Form Data to a text file on hard drive

Threaded View

  1. #1
    Join Date
    Jun 2006
    Location
    Asheboro, NC
    Posts
    3

    Send Form Data to a text file on hard drive

    I found this script that will save form data to a text file on my hard drive.
    It does what I’m looking for except. The only thing I would like to add is the use of radio buttons. If anyone could show me how to do this, it would be greatly appreciated.

    All the fields work fine and saving the info to a file except the radio button
    Selection.

    Below is an example of the output…

    , , , , Software, undefined

    The radio button veritable is undefined and I’m not sure how to correct this.

    Thanks
    Greg
    Code:
    <SCRIPT LANGUAGE='JavaScript'> 
    function WriteToFile() {
     try {
       var fso, s;
    0   fso = new ActiveXObject("Scripting.FileSystemObject");
       s = fso.OpenTextFile("C:\\ietm_data.txt" , 8, 1, -2);   
       s.writeline(document.ietmdata.name.value + ", " +  document.ietmdata.email.value + ", " + 
    
    document.ietmdata.location.value + ", " +  document.ietmdata.comments.value + ", " + 
    document.ietmdata.type.value + ", " +  document.ietmdata.problem.value);
    s.Close();
     }
    catch(err){
      var strErr = 'Error:';
      strErr += '\nNumber:' + err.number;
      strErr += '\nDescription:' + err.description;
      document.write(strErr);
     }
    }
    
    </SCRIPT> 
    <BODY>
    
    <form action="test.hta" method="post" name="ietmdata">
    Name:     <input type = "text" name="name"><br>
    Email: <input type="text" name="email"><br>
    Location: <input type = "text" name="location"><br>
    Comments: <textarea name="comments"> </textarea><br>
    
    Type: <select name="type">
        
         <option value="Software"> Software </option>
         <option value="Hardware"> Hardware </option>
    
    </select>
    
    <br>
    <br>
     <p> 
      Requesting information:<BR> 
    
           <input type="radio" name="problem" value="Option 1"> Option 1<br>
           <input type="radio" name="problem" value="Option 2"> Option 2<br>
    
      </p> 
      <p>
    
    <br>
    <br>
    <br>
    <INPUT TYPE=BUTTON VALUE="Submit Data to Text File" onClick="WriteToFile(this.form)">
    </form>
    Last edited by jedaisoul; 05-01-2014 at 03:22 PM. Reason: code tags added

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles