Question : Hta code change as feedback form.

Hi,

I have the below code that when entered data stores the user selected data into a log file. I want some changes in the script. As the attachment want to change some portions towards feedback form. Please see attachment.

Any help is great use.

Regards
Sharath
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
'====================
<head>
<title>User Information Form</title>
<HTA:APPLICATION 
     APPLICATIONNAME="User Information Form"
     BORDER="thin"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
</head>

<script language="VBScript">

' Global variable to hold the path to the text files
' they are defined here to be global, but are assigned
' values in the Window_OnLoad procedure
strTextLogPath = ""
strLogFile = ""

Sub Window_OnLoad
      intWidth = 800
      intHeight = 600
      Me.ResizeTo intWidth, intHeight
    Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
    'cbo_building.Style.Width = 180
    'cbo_floor.Style.Width = 180
      Set objNetwork = CreateObject("WScript.Network")
      txt_loginname.Value = objNetwork.UserName
      txt_machinename.Value = objNetwork.ComputerName

      ' This line gets the path from the currently running directory of this HTA
      strTextLogPath = Mid(Replace(Replace(document.URL, "file://", ""), "%20", " "), 1, InStrRev(Replace(Replace(document.URL, "file://", ""), "%20", " "), "\"))
      
      If Right(strTextLogPath, 1) <> "\" Then strTextLogPath = strTextLogPath & "\"
      ' This line appends username.txt to that path
      strLogFile =  strTextLogPath & txt_loginname.Value & ".txt"
      ' This retrieves the user name for the user
      Set objADSysInfo = CreateObject("ADSystemInfo")
      txt_name.Value = Replace(Split(objADSysInfo.UserName, ",")(0), "CN=", "")
      Set objUser = GetObject("LDAP://" & objADSysInfo.UserName)
      txt_email.Value = objUser.Mail
      txt_designation.Value = Left(objUser.Title, 50)
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      If objFSO.FileExists(strLogFile) Then
            MsgBox "Your information has already been submitted.  Thank you."
            window.Close
      End If
      Set objFSO = Nothing
End Sub

Sub Default_Buttons
      If Window.Event.KeyCode = 13 Then
            btn_submit.Click
      End If
End Sub

Sub Populate_cbo_floor()

      ' POPULATE THE FLOORS LIST BOX DEPENDING ON SELECTION OF BUILDING
      
      strHTML = "<select size='1' id='cbo_floor' name='cbo_floor'>" & VbCrLf
      strHTML = strHTML & "<option id='opt_none' value='opt_none' selected> --- Select Floor --- </option>" & VbCrLf
      
      If cbo_building.Value = "Shafika" Then
            txt_city.Value = "Chennai"
            strHTML = strHTML & "<option id='opt_gfloor' value='G Floor'>G Floor</option>" & VbCrLf
            strHTML = strHTML & "<option id='opt_1stfloor' value='1st Floor'>1st Floor</option>" & VbCrLf
            strHTML = strHTML & "<option id='opt_3rdfloor' value='3rd Floor'>3rd Floor</option>" & VbCrLf
            strHTML = strHTML & "<option id='opt_4thfloor' value='4th Floor'>4th Floor</option>" & VbCrLf
      ElseIf cbo_building.Value = "Hafiz Court" Then
            txt_city.Value = "Chennai"
            strHTML = strHTML & "<option id='opt_gfloor' value='G Floor'>G Floor</option>" & VbCrLf
            strHTML = strHTML & "<option id='opt_1stfloor' value='1st Floor'>1st Floor</option>" & VbCrLf
            strHTML = strHTML & "<option id='opt_2ndfloor' value='2nd Floor'>2nd Floor</option>" & VbCrLf
            strHTML = strHTML & "<option id='opt_3rdfloor' value='3rd Floor'>3rd Floor</option>" & VbCrLf
            strHTML = strHTML & "<option id='opt_4thfloor' value='4th Floor'>4th Floor</option>" & VbCrLf
      ElseIf cbo_building.Value = "Hafiz Fort" Then
            txt_city.Value = "Chennai"
            strHTML = strHTML & "<option id='opt_gfloor' value='G Floor'>G Floor</option>" & VbCrLf
            strHTML = strHTML & "<option id='opt_1stfloor' value='1st Floor'>1st Floor</option>" & VbCrLf
      ElseIf cbo_building.Value = "GR Plaza" Then
            txt_city.Value = "Chennai"
            strHTML = strHTML & "<option id='opt_gfloor' value='G Floor'>G Floor</option>" & VbCrLf
            strHTML = strHTML & "<option id='opt_1stfloor' value='1st Floor'>1st Floor</option>" & VbCrLf
            strHTML = strHTML & "<option id='opt_2ndfloor' value='2nd Floor'>2nd Floor</option>" & VbCrLf
            strHTML = strHTML & "<option id='opt_3rdfloor' value='3rd Floor'>3rd Floor</option>" & VbCrLf
      ElseIf cbo_building.Value = "Titus Towers" Then
            txt_city.Value = "Hyderabad"
            strHTML = strHTML & "<option id='opt_3rdfloor' value='3rd Floor'>3rd Floor</option>" & VbCrLf
      Else
            txt_city.Value = ""
      End If

      strHTML = strHTML & "</select>"
      span_floor.InnerHTML = strHTML

End Sub

Sub Submit_Form
      If txt_name.Value = "" Then
            MsgBox "Please enter your full name in the Name field."
            txt_name.Focus
      ElseIf txt_empid.Value = "" Then
            MsgBox "Please enter your Employee ID in the Emp ID field."
            txt_empid.Focus
      ElseIf cbo_building.Value = "opt_none" Then
            MsgBox "Please select your building from the Building drop down box."
            cbo_building.Focus
      ElseIf cbo_floor.Value = "opt_none" Then
            MsgBox "Please select your floor from the Floor drop down box."
            cbo_floor.Focus
      ElseIf txt_seatno.Value = "" Then
            MsgBox "Please enter your seat number in the Seat No field."
            txt_seatno.Focus
      ElseIf txt_designation.Value = "" Then
            MsgBox "Please enter your designation in the Designation field."
            txt_designation.Focus
      ElseIf txt_extensionno.Value = "" Then
            MsgBox "Please enter your extension number in the Extension No field."
            txt_extensionno.Focus
      ElseIf Len(txt_extensionno.Value) <> 4 Then
            MsgBox "Please enter a 4 digit extension number in the Extension No field."
            txt_extensionno.Focus
      Else
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            Set objOutputFile = objFSO.CreateTextFile(strLogFile, True)
            'objOutputFile.Write """Full Name;Login Name;Employee ID;Seat Number;Designation;Machine Name;Extension Number"""
            'objOutputFile.Write VbCrLf & """" & txt_name.Value & ";" & txt_loginname.Value & ";" & txt_empid.Value & ";" & txt_seatno.Value & ";" & txt_designation.Value & ";" & txt_machinename.Value & ";" & txt_extensionno.Value & """"
            objOutputFile.Write "Full Name;Login Name;Email;Employee ID;Building;Floor;Seat Number;City;Designation;Machine Name;Extension Number"
            objOutputFile.Write VbCrLf & txt_name.Value & ";" & txt_loginname.Value & ";" & txt_email.Value & ";" & txt_empid.Value & ";" & cbo_Building.Value & ";" & cbo_Floor.Value & ";" & txt_seatno.Value & ";" & txt_City.Value & ";" & txt_designation.Value & ";" & txt_machinename.Value & ";" & txt_extensionno.Value
            objOutputFile.Close
            Set objOutputFile = Nothing
            Set objFSO = Nothing
            MsgBox "Thank you for submitting your information."
            window.Close
      End If
End Sub

Sub Validate_Keys(strField)
      If LCase(strField) = "designation" Then
            If Window.Event.KeyCode >= 48 And Window.Event.KeyCode <= 57 Then Window.Event.KeyCode = Null
      ElseIf LCase(strField) = "extensionno" Then
            If (Window.Event.KeyCode < 48 Or Window.Event.KeyCode > 57) And Window.Event.KeyCode <> 13 Then Window.Event.KeyCode = Null
      End If
End Sub

</script>

<body STYLE="font:14 pt arial; color:white;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
      <table width='90%' height = '100%' align='center' border='0'>
            <tr>
                  <td align='center'>
                        <h3>User Information Form</h3><br>
                  </td>
            </tr
            <tr>
                  <td align='center'>
                        <table>
                              <tr>
                                    <td>
                                          Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_name" name="txt_name" readonly>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Login Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_loginname" name="txt_loginname" readonly>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Email Address:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="50" size="70" id="txt_email" name="txt_email" readonly>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Emp ID:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="6" size="10" id="txt_empid" name="txt_emptid">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Building:
                                    </td>
                                    <td>
                                          <select size="1" id="cbo_building" name="cbo_building" onChange='Populate_cbo_floor()'>
                                                <option id="opt_none" value="opt_none" selected> --- Select Building --- </option>
                                                <option id="opt_shafika" value="Shafika">Shafika</option>
                                                <option id="opt_hafizcourt" value="Hafiz Court">Hafiz Court</option>
                                                <option id="opt_grplaza" value="GR Plaza">GR Plaza</option>
                                                <option id="opt_hafizfort" value="Hafiz Fort">Hafiz Fort</option>
                                                <option id="opt_titustowers" value="Titus Towers">Titus Towers</option>
                                          </select>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Floor:
                                    </td>
                                    <td>
                                          <span id="span_floor">
                                                <select size="1" id="cbo_floor" name="cbo_floor">
                                                      <option id="opt_none" value="opt_none" selected> --- Select Floor --- </option>
                                                </select>
                                          </span>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Seat No:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="10" size="15" id="txt_seatno" name="txt_seatno">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          City:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="16" size="25" id="txt_city" name="txt_city" readonly>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Designation:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="50" size="70" id="txt_designation" name="txt_designation" onkeypress="vbs:Validate_Keys('designation')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Machine Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="16" size="25" id="txt_machinname" name="txt_machinename" readonly>
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Extension No:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="4" size="10" id="txt_extensionno" name="txt_extensionno" onkeypress="vbs:Validate_Keys('extensionno')">
                                    </td>
                              </tr>
                        </table>
                  </td>
            </tr>
            <tr>
                  <td align='center'>
                        <br>Please note that all fields are required.
                  </td>
            </tr>            
            <tr>
                  <td align='center'>
                        <input type="button" value="Submit" name="btn_submit"  onClick="vbs:Submit_Form"><br><br>
                  </td>
            </tr>
            <tr>
                  <td align="right">
                        This information is required to keep<br>
                        your details up to date in our database
                  </td>
            </tr>
      </table>
</body>
'====================
Attachments:
 
Sample
 

Answer : Hta code change as feedback form.

If you can ping google that means you have internet connection. Try opening a command prompt and type "netstat -nbo" ... this will show you tha established connections and the application that is associated with the connection. Also, check the proxy settings on your internet browser. Try running IE in safe mode (with add-ons disabled).  To check for virus/malware, if you know the date that the computer got infected, start the computer in safe mode. Then check for *.exe and *.dll files in the most common places where a virus would be stored. You can do so by opening a command prompt and typing "dir /o-d /a /p *.exe" or "dir /o-d /a /p *.dll". This will show you *.exe and *.dll files in order by date with the latest ones at the top. You can hit the space bar to scroll down the list. Run these commands in \windows, \windows\system32, %userprofile% (and subfolders by adding the /s switch to the commabd) and in the \program files folder and subfolders. Delete any *.dll or *.exe file that looks suspicious. If you're not sure about a file you can google the name of the file.
Random Solutions  
 
programming4us programming4us