title: How to write form value to local text file?
body: <p>I'm creating an hta file that will only ever be run on my local machine. When I input a value into the form field and click the submit button, I'd like the value to overwrite any other text within the file C:\data.txt . I can't figure out why this won't work.. (I've read many similar posts with no luck)</p>
  
  <p>This is the relevant HTML I have:</p>
  
  <pre><code>&lt;input type="text" name="Keyword" value=""&gt;
  &lt;input type="button" value="Submit!" class="myButton" onClick="SaveData"&gt;
  </code></pre>
  
  <p>and here is the script I'm using:</p>
  
  <pre><code>&lt;SCRIPT Language="VBScript"&gt;
      Sub SaveData
          Set objFSO = CreateObject("Scripting.FileSystemObject")
          If objFSO.FileExists("C:\data.txt") Then
             Set objFile = objFSO.OpenTextFile("C:\data.txt", 8)
              strLine = Keyword.Value &amp; vbTab
              objFile.WriteLine strLine
              objFile.Close
          Else
              Set objFile = objFSO.CreateTextFile("C:\data.txt")
              strLine = keyword.Value &amp; vbTab
              objFile.WriteLine strLine
              objFile.Close
          End If
      End Sub
  
  &lt;/SCRIPT&gt;--&gt;
  </code></pre>
  
  <p>The script sits just above the &lt; body > tag. Why is no file created when I click the submit button? Thank you!!</p>