Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was stumped, so I rewrote this in vbscript.</p> <p>I have included bits of what I did to give you an idea of how to write to a text file, and validate your form with an HTA.</p> <p>The vbscript:</p> <pre><code>Set wshShell = CreateObject( "WScript.Shell" ) strSender = wshShell.ExpandEnvironmentStrings( "%USERNAME%" ) ' Get the current Username Dim Checkmark Sub Validate If form.Flag.checked = True Then ' Find out if your Checkbox is checked Checkmark = "*" Else Checkmark = "" End IF If form.field1.value = "" Then ' Validate the form alert "Please enter an number!", "0", "Title" ElseIf IsNumeric(form.field1.value) = False Then alert "Please enter a valid number!", "0", "Title" ElseIf form.drop_down1.Value = "" Then alert "Please select a save location!", "0", "Title" ElseIf form.field1.value &lt; 100000 Then alert "Please enter a six digit number!", "0", "Title" ElseIf form.field1.value &gt; 999999 Then alert "Please enter a six digit number!", "0", "Title" Else SaveData End If End Sub Sub SaveData ' Write data to a text file Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FileExists(form.drop_down1.Value) Then Set objFile = objFSO.OpenTextFile(form.drop_down1.Value, 8) strLine = form.field1.value &amp; vbtab &amp; Checkmark &amp; vbtab &amp; strSender &amp; vbtab &amp; Now ' fields that will be written objFile.WriteLine strLine MsgBox "The Information was successfully written to the file.", "0", "Title" objFile.Close Else Set objFile = objFSO.CreateTextFile(form.drop_down1.Value) ' If file does not exist, create file strLine = form.field1.value &amp; vbtab &amp; Checkmark &amp; vbtab &amp; strSender &amp; vbtab &amp; Now objFile.WriteLine strLine MsgBox "The Information was successfully written to the file.", "0", "Title" objFile.Close End If End Sub </code></pre> <p>The HTML:</p> <pre><code>&lt;form name="form"&gt; &lt;h2&gt;Imput&lt;/h2&gt; &lt;tr&gt;&lt;td&gt;&lt;lable&gt;Data: &lt;/lable&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="field1" size="25"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;lable&gt;Save Location: &lt;/lable&gt;&lt;/td&gt;&lt;td&gt;&lt;select name="drop_down1"&gt; &lt;option type="text" name="select" value=""&gt;Select an option&lt;/option&gt; &lt;option type="text" value="SavePath1..."&gt;SavePath1&lt;/option&gt; &lt;option type="text" value="SavePath2..."&gt;SavePath2&lt;/option&gt; &lt;option type="text" value="SavePath3..."&gt;SavePath3&lt;/option&gt; &lt;/select&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="checkbox" name="Flag" value=""&gt;Flag *&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;input type="button" value="Submit" onClick="Validate"&gt; &lt;input type='reset' id='ResetFields' value='Clear Fields' /&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload