'====================
<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>
'====================
|