Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Hta file that gets data from Active directory GAL on any of the mentioned fields.

Posted on 2008-06-11
17
Medium Priority
?
505 Views
Last Modified: 2010-04-16
Hi,

Hta file that gets data from GAL on any of the mentioned fields.

The notes has the machine name.When it gets the machine name when entering other data. I want the "Machine name :" not to appear.
And
When i enter just the machine name it dos not get the data. As the machine name is also in the Notes box.

Need these 2 changs please...

Regards
Sharath

<head>
<title>User Information</title>
<HTA:APPLICATION 
     APPLICATIONNAME="User Information"
     BORDER="thin"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
</head>
 
<script language="VBScript">
 
' Global variables
Dim arrRows
 
Sub Window_OnLoad
      intWidth = 800
      intHeight = 900
      Me.ResizeTo intWidth, intHeight
      Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
      btnFirstEvent.Disabled = True
      btnPreviousEvent.Disabled = True
      btnNextEvent.Disabled = True
      btnLastEvent.Disabled = True
      btnFirstEvent.Style.Visibility = "Hidden"
      btnPreviousEvent.Style.Visibility = "Hidden"
      btnNextEvent.Style.Visibility = "Hidden"
      btnLastEvent.Style.Visibility = "Hidden"
End Sub
 
Sub Default_Buttons
      If Window.Event.KeyCode = 13 Then
            btn_submit.Click
      ElseIf Window.Event.KeyCode = 27 Then
            Clear_Form
      End If      
End Sub
 
Sub Clear_Form
      txt_seatno.Value = ""
      txt_seatno.style.backgroundColor="#FFFFFF"
      txt_seatno.Disabled = False
      txt_extensionno.Value = ""
      txt_extensionno.style.backgroundColor="#FFFFFF"
      txt_extensionno.Disabled = False
      txt_empid.Value = ""
      txt_empid.style.backgroundColor="#FFFFFF"
      txt_empid.Disabled = False
      txt_department.Value = ""
      txt_department.style.backgroundColor="#FFFFFF"
      txt_department.Disabled = False
      txt_designation.Value = ""
      txt_designation.style.backgroundColor="#FFFFFF"
      txt_designation.Disabled = False
      txt_name.Value = ""
      txt_name.style.backgroundColor="#FFFFFF"
      txt_name.Disabled = False
      txt_loginname.Value = ""
      txt_loginname.style.backgroundColor="#FFFFFF"
      txt_loginname.Disabled = False
      txt_email.Value = ""
      txt_email.style.backgroundColor="#FFFFFF"
      txt_email.Disabled = False
      txt_notes.Value = ""
      txt_notes.style.backgroundColor="#FFFFFF"
      txt_notes.Disabled = False
      txt_mobileno.Value = ""
      txt_mobileno.style.backgroundColor="#FFFFFF"
      txt_mobileno.Disabled = False
      txt_company.Value = ""
      txt_company.style.backgroundColor="#FFFFFF"
      txt_company.Disabled = False
      txt_address.Value = ""
      txt_address.style.backgroundColor="#FFFFFF"
      txt_address.Disabled = False
      txt_city.Value = ""
      txt_city.style.backgroundColor="#FFFFFF"
      txt_city.Disabled = False
      txt_state.Value = ""
      txt_state.style.backgroundColor="#FFFFFF"
      txt_state.Disabled = False
      txt_zipcode.Value = ""
      txt_zipcode.style.backgroundColor="#FFFFFF"
      txt_zipcode.Disabled = False
      txt_country.Value = ""
      txt_country.style.backgroundColor="#FFFFFF"
      txt_country.Disabled = False
      txt_homephone.Value = ""
      txt_homephone.style.backgroundColor="#FFFFFF"
      txt_homephone.Disabled = False
      btnFirstEvent.Style.Visibility = "Hidden"
      btnPreviousEvent.Style.Visibility = "Hidden"
      btnNextEvent.Style.Visibility = "Hidden"
      btnLastEvent.Style.Visibility = "Hidden"
      span_currentrecord.InnerHTML = "0"
      span_totalrecords.InnerHTML = "0"
End Sub
 
Sub Submit_Form
 
      arrFields = Array(_
      		"txt_seatno", _
            "txt_extensionno", _
            "txt_empid", _
            "txt_department", _
            "txt_designation", _
            "txt_name", _
            "txt_loginname", _
            "txt_email", _
            "txt_notes", _
            "txt_mobileno", _
            "txt_company", _
            "txt_address", _
            "txt_city", _
            "txt_state", _
            "txt_zipcode", _
            "txt_country", _
            "txt_homephone" _
      )
      
      boolValid = False
      For Each strField In arrFields
            If Eval(strField & ".Disabled") = True Then
                  boolValid = True
            End If
            If Eval(strField & ".Disabled") = False Then
                  strCurrentField = strField
            End If
      Next
      
      If boolValid = False Then strCurrentField = "INVALID"
      
      Select Case strCurrentField
            Case "txt_seatno"
                  If txt_seatno.Value = "" Then
                              strSearchField = "(physicalDeliveryOfficeName=*)"
                        Else
                              strSearchField = "(physicalDeliveryOfficeName=*" & txt_seatno.Value & "*)"
                        End If
            Case "txt_extensionno"
                  If txt_extensionno.Value = "" Then
                        strSearchField = "(telephoneNumber=*)"
                  Else
                              strSearchField = "(telephoneNumber=*" & txt_extensionno.Value & "*)"
                        End If
            Case "txt_empid"
                  If txt_empid.Value = "" Then
                        strSearchField = "(description=*)"
                  Else
                              strSearchField = "(description=*" & txt_empid.Value & "*)"
                        End If
            Case "txt_department"
                  If txt_department.Value = "" Then
                        strSearchField = "(department=*)"
                  Else
                              strSearchField = "(department=*" & txt_department.Value & "*)"
                        End If
            Case "txt_designation"
                  If txt_designation.Value = "" Then
                        strSearchField = "(title=*)"
                  Else
                              strSearchField = "(title=*" & txt_designation.Value & "*)"
                        End If
            Case "txt_name"
                  If txt_name.Value = "" Then
                              strSearchField = "(cn=*)"
                        Else
                              strSearchField = "(cn=*" & txt_name.Value & "*)"
                        End If
            Case "txt_loginname"
                  If txt_loginname.Value = "" Then
                        strSearchField = "(samAccountName=*)"
                  Else
                              strSearchField = "(samAccountName=*" & txt_loginname.Value & "*)"
                        End If
            Case "txt_email"
                  If txt_email.Value = "" Then
                        strSearchField = "(mail=*)"
                  Else
                              strSearchField = "(mail=*" & txt_email.Value & "*)"
                        End If
            Case "txt_notes"
                  If txt_notes.Value = "" Then
                        strSearchField = "(info=*)"
                  Else
                              strSearchField = "(info=*" & txt_notes.Value & "*)"
                        End If
            Case "txt_mobileno"
                  If txt_mobileno.Value = "" Then
                        strSearchField = "(mobile=*)"
                  Else
                              strSearchField = "(mobile=*" & txt_mobileno.Value & "*)"
                        End If
            Case "txt_company"
                  If txt_company.Value = "" Then
                        strSearchField = "(company=*)"
                  Else
                              strSearchField = "(company=*" & txt_company.Value & "*)"
                        End If
            Case "txt_address"
                  If txt_address.Value = "" Then
                        strSearchField = "(streetAddress=*)"
                  Else
                              strSearchField = "(streetAddress=*" & txt_address.Value & "*)"
                        End If
            Case "txt_city"
                  If txt_city.Value = "" Then
                        strSearchField = "(l=*)"
                  Else
                              strSearchField = "(l=*" & txt_city.Value & "*)"
                        End If
            Case "txt_state"
                  If txt_state.Value = "" Then
                        strSearchField = "(st=*)"
                  Else
                              strSearchField = "(st=*" & txt_state.Value & "*)"
                        End If
            Case "txt_zipcode"
                  If txt_zipcode.Value = "" Then
                        strSearchField = "(postalCode=*)"
                  Else
                              strSearchField = "(postalCode=*" & txt_zipcode.Value & "*)"
                        End If
            Case "txt_country"
                  If txt_country.Value = "" Then
                        strSearchField = "(c=*)"
                  Else
                              strSearchField = "(c=*" & txt_country.Value & "*)"
                        End If
            Case "txt_homephone"
                  If txt_homephone.Value = "" Then
                        strSearchField = "(homePhone=*)"
                  Else
                              strSearchField = "(homePhone=*" & txt_homephone.Value & "*)"
                        End If
            Case Else
                  strSearchField = "INVALID"
      End Select
 
      Clear_Form
      
      If strSearchField <> "INVALID" Then
            Set adoCommand = CreateObject("ADODB.Command")
            Set adoConnection = CreateObject("ADODB.Connection")
            adoConnection.Provider = "ADsDSOObject"
            adoConnection.Open "Active Directory Provider"
            adoCommand.ActiveConnection = adoConnection
            
             ' Search entire Active Directory domain.
            Set objRootDSE = GetObject("LDAP://RootDSE")
            
            strDNSDomain = objRootDSE.Get("defaultNamingContext")
            strBase = "<LDAP://" & strDNSDomain & ">"
            
            strFilter = "(&(objectCategory=person)(objectClass=user)" & strSearchField & ")"
            'strFilter = "(&(objectClass=computer)(cn=" & strComputer & "))"
            
            ' Comma delimited list of attribute values to retrieve.
            strAttributes = "physicalDeliveryOfficeName,TelephoneNumber,description,Department,Title,cn,samAccountName,mail,Info,Mobile,company,streetAddress,l,st,postalCode,c,homePhone"
            
            ' Construct the LDAP syntax query.
            strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
            adoCommand.CommandText = strQuery
            adoCommand.Properties("Page Size") = 100
            adoCommand.Properties("Timeout") = 30
            adoCommand.Properties("Cache Results") = False
 
            ' Run the query.
            Set adoRecordset = adoCommand.Execute
             
            ' Enumerate the resulting recordset.
            strDetails = ""
            If Not adoRecordset.EOF Then
                  Do Until adoRecordset.EOF
                        If strDetails = "" Then
                              strDetails = adoRecordset.Fields("physicalDeliveryOfficeName").Value &_
                                                "|TD|" & adoRecordset.Fields("TelephoneNumber").Value
                                                If IsNull(adoRecordset.Fields("Description").Value) = False Then
                                                      strDetails = strDetails & "|TD|" & Join(adoRecordset.Fields("description").Value)
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Title").Value &_
                                                "|TD|" & adoRecordset.Fields("Department").Value &_
                              					"|TD|" & Replace(adoRecordset.Fields("cn").Value, "CN=", "") &_
                                                "|TD|" & adoRecordset.Fields("samAccountName").Value &_
                                                "|TD|" & adoRecordset.Fields("mail").Value
                                                If IsNull(adoRecordset.Fields("Info").Value) = False Then
                                                      strDetails = strDetails & "|TD|" & Replace(adoRecordset.Fields("Info").Value, "Machine Name - ", "")
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Mobile").Value &_
                                                "|TD|" & adoRecordset.Fields("company").Value &_
                                                "|TD|" & adoRecordset.Fields("streetAddress").Value &_
                                                "|TD|" & adoRecordset.Fields("l").Value &_
                                                "|TD|" & adoRecordset.Fields("st").Value &_
                                                "|TD|" & adoRecordset.Fields("postalCode").Value &_
                                                "|TD|" & adoRecordset.Fields("c").Value &_
                                                "|TD|" & adoRecordset.Fields("homePhone").Value
                        Else
                              strDetails = strDetails & "|TR|" & adoRecordset.Fields("physicalDeliveryOfficeName").Value &_
                                                "|TD|" & adoRecordset.Fields("TelephoneNumber").Value
                                                If IsNull(adoRecordset.Fields("Description").Value) = False Then
                                                      strDetails = strDetails & "|TD|" & Join(adoRecordset.Fields("description").Value)
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Title").Value &_
                                                "|TD|" & adoRecordset.Fields("Department").Value &_
                              					"|TD|" & Replace(adoRecordset.Fields("cn").Value, "CN=", "") &_
                                                "|TD|" & adoRecordset.Fields("samAccountName").Value &_
                                                "|TD|" & adoRecordset.Fields("mail").Value
                                                If IsNull(adoRecordset.Fields("Info").Value) = False Then
                                                      strDetails = strDetails & "|TD|" & Replace(adoRecordset.Fields("Info").Value, "Machine Name - ", "")
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Mobile").Value &_
                                                "|TD|" & adoRecordset.Fields("company").Value &_
                                                "|TD|" & adoRecordset.Fields("streetAddress").Value &_
                                                "|TD|" & adoRecordset.Fields("l").Value &_
                                                "|TD|" & adoRecordset.Fields("st").Value &_
                                                "|TD|" & adoRecordset.Fields("postalCode").Value &_
                                                "|TD|" & adoRecordset.Fields("c").Value &_
                                                "|TD|" & adoRecordset.Fields("homePhone").Value
                        End If
                      adoRecordset.MoveNext
                  Loop
            Else
                  MsgBox "No records were found"
            End If
            
            ' Clean up.
            adoRecordset.Close
            Set adoRecordset = Nothing
            
            adoConnection.Close
      
            If strDetails <> "" Then
                  arrRows = ""
                  arrRows = Split(strDetails, "|TR|")
                  If UBound(arrRows) < 0 Then
                        span_currentrecord.InnerHTML = "0"
                        span_totalrecords.InnerHTML = "0"
                  Else
                        arrData = Split(arrRows(0), "|TD|")
						txt_seatno.Value = arrData(0)
                        txt_extensionno.Value = arrData(1)
                        txt_empid.Value = arrData(2)
                        txt_department.Value = arrData(3)
                        txt_designation.Value = arrData(4)
                        txt_name.Value = arrData(5)
                        txt_loginname.Value = arrData(6)
                        txt_email.Value = arrData(7)
                        txt_notes.Value = arrData(8)
                        txt_mobileno.Value = arrData(9)
                        txt_company.Value = arrData(10)
                        txt_address.Value = arrData(11)
                        txt_city.Value = arrData(12)
                        txt_state.Value = arrData(13)
                        txt_zipcode.Value = arrData(14)
                        txt_country.Value = arrData(15)
                        txt_homephone.Value = arrData(16)
                        span_currentrecord.InnerHTML = "1"
                        span_totalrecords.InnerHTML = UBound(arrRows) + 1
                  End If
            Else
                  span_currentrecord.InnerHTML = "0"
                  span_totalrecords.InnerHTML = "0"
            End If
            If strDetails = "" Then
                  btnFirstEvent.Disabled = True
                  btnPreviousEvent.Disabled = True
                  btnNextEvent.Disabled = True
                  btnLastEvent.Disabled = True      
                  btnFirstEvent.Style.Visibility = "Hidden"
                  btnPreviousEvent.Style.Visibility = "Hidden"
                  btnNextEvent.Style.Visibility = "Hidden"
                  btnLastEvent.Style.Visibility = "Hidden"
            ElseIf UBound(arrRows) = 0 Then
                  btnFirstEvent.Disabled = True
                  btnPreviousEvent.Disabled = True
                  btnNextEvent.Disabled = True
                  btnLastEvent.Disabled = True
                  btnFirstEvent.Style.Visibility = "Hidden"
                  btnPreviousEvent.Style.Visibility = "Hidden"
                  btnNextEvent.Style.Visibility = "Hidden"
                  btnLastEvent.Style.Visibility = "Hidden"
            Else
                  btnFirstEvent.Disabled = False
                  btnPreviousEvent.Disabled = False
                  btnNextEvent.Disabled = False
                  btnLastEvent.Disabled = False
                  btnFirstEvent.Style.Visibility = "Visible"
                  btnPreviousEvent.Style.Visibility = "Visible"
                  btnNextEvent.Style.Visibility = "Visible"
                  btnLastEvent.Style.Visibility = "Visible"
            End If
      Else
            MsgBox "Please type a search request into one of the fields, then click Submit."
      End If
      
End Sub
 
Sub Get_Event
 
	arrData = Split(arrRows(span_currentrecord.InnerHTML - 1), "|TD|")
	txt_seatno.Value = arrData(0)
	txt_extensionno.Value = arrData(1)
	txt_empid.Value = arrData(2)
	txt_department.Value = arrData(3)
	txt_designation.Value = arrData(4)
	txt_name.Value = arrData(5)
	txt_loginname.Value = arrData(6)
	txt_email.Value = arrData(7)
	txt_notes.Value = arrData(8)
	txt_mobileno.Value = arrData(9)
	txt_company.Value = arrData(10)
	txt_address.Value = arrData(11)
	txt_city.Value = arrData(12)
	txt_state.Value = arrData(13)
	txt_zipcode.Value = arrData(14)
	txt_country.Value = arrData(15)
	txt_homephone.Value = arrData(16)
 
End Sub
 
Sub First_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_totalrecords.InnerHTML < 1 Then
                  MsgBox "There are no records to display"
            ElseIf span_currentrecord.InnerHTML = 1 Then
                  MsgBox "You are already viewing the first record."
            Else
                  span_currentrecord.InnerHTML = 1
                  Get_Event
            End If
      End If
      
End Sub
 
Sub Previous_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_currentrecord.InnerHTML > 1 Then
                  span_currentrecord.InnerHTML = span_currentrecord.InnerHTML - 1
                  Get_Event
            ElseIf span_currentrecord.InnerHTML = 1 Then
                        MsgBox "You are already viewing the first record."
            Else
                  MsgBox "There are no records to display"
            End If
      End If
 
End Sub
 
Sub Next_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_totalrecords.InnerHTML = 0 Then
                  MsgBox "There are no records for to display"
            ElseIf span_currentrecord.InnerHTML = span_totalrecords.InnerHTML Then
                  MsgBox "You are already viewing the last record."
            Else
                  span_currentrecord.InnerHTML = span_currentrecord.InnerHTML + 1
                  Get_Event
            End If
      End If
      
End Sub
 
Sub Last_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_totalrecords.InnerHTML = 0 Then
                  MsgBox "There are no records to display"
            ElseIf span_currentrecord.InnerHTML = span_totalrecords.InnerHTML Then
                        MsgBox "You are already viewing the last record."
            Else
                  span_currentrecord.InnerHTML = span_totalrecords.InnerHTML
                  Get_Event
            End If
      End If
      
End Sub
 
Sub Detect_Search_Field(strCurrentField)
      arrFields = Array(_
      		"txt_seatno", _
            "txt_extensionno", _
            "txt_empid", _
            "txt_department", _
            "txt_designation", _
            "txt_name", _
            "txt_loginname", _
            "txt_email", _
            "txt_notes", _
            "txt_mobileno", _
            "txt_company", _
            "txt_address", _
            "txt_city", _
            "txt_state", _
            "txt_zipcode", _
            "txt_country", _
            "txt_homephone" _
      )
      
      For Each strField In arrFields
            If LCase(strField) <> LCase(strCurrentField) Then
                  Execute strField & ".style.backgroundColor=""#D3D3D3"""
                  Execute strField & ".Disabled = True"
            End If
      Next
End Sub
 
Sub RunScript
      strAnswer = window.prompt("Please enter the Location to save.", "C:\HTAResults.csv")
 
      If IsNull(strAnswer) Then
            Msgbox "You clicked the Cancel button"
      Else
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            If objFSO.FileExists(strAnswer) = True Then
                  Set objFile = objFSO.OpenTextFile(strAnswer, 8, False)
            Else
                  Set objFile = objFSO.CreateTextFile(strAnswer, True)
                  objFile.Write """Seat No"",""Extension"",""Emp ID"",""Department"",""Designation"",""User Name"",""Login Name"",""Email Address"",""Computer"",""Mobile"",""Company"",""Address"",""City"",""State"",""Zip Code"",""Country"",""Home Phone"""
            End If
      
                  For intRow = LBound(arrRows) To UBound(arrRows)
                        arrData = Split(arrRows(intRow), "|TD|")
                  objFile.Write VbCrLf & """" & arrData(0) & """,""" & arrData(1) & """,""" & arrData(2) & """,""" & arrData(3) & _
                        """,""" & arrData(4) & """,""" & arrData(5) & """,""" & arrData(6) & """,""" & arrData(7) & _
                        """,""" & arrData(8) & """,""" & arrData(9) & """,""" & arrData(10) & """,""" & arrData(11) & _
                        """,""" & arrData(12) & """,""" & arrData(13) & """,""" & arrData(14) & """,""" & arrData(15) & _
                        """,""" & arrData(16) & """"
                  Next
            objFile.Close
            MsgBox "Saved."
      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><tr><td align='right'><img src='G:\Tools\oemlogo.bmp'></td></tr></table>     
 <table width='90%' height = '100%' align='center' border='0'>
            <tr>
                  <td align='center' colspan="2">
                        <h3>User Information</h3><br>
                  </td>
            </tr
            <tr>
                  <td align='center' colspan="2">
                        <table border="0">
                              <tr>
                                    <td>
                                          Seat No:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_seatno" name="txt_seatno" onkeypress="vbs:Detect_Search_Field('txt_seatno')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Extension No:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="25" size="40" id="txt_extensionno" name="txt_extensionno" onkeypress="vbs:Detect_Search_Field('txt_extensionno')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Emp ID:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="6" size="10" id="txt_empid" name="txt_empid" onkeypress="vbs:Detect_Search_Field('txt_empid')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Department:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="50" id="txt_department" name="txt_department" onkeypress="vbs:Detect_Search_Field('txt_department')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Designation:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="50" size="70" id="txt_designation" name="txt_designation" onkeypress="vbs:Detect_Search_Field('txt_designation')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          User Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_name" name="txt_name" onkeypress="vbs:Detect_Search_Field('txt_name')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Login Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_loginname" name="txt_loginname" onkeypress="vbs:Detect_Search_Field('txt_loginname')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Email Address:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="50" size="70" id="txt_email" name="txt_email" onkeypress="vbs:Detect_Search_Field('txt_email')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                         Machine Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="16" size="20" id="txt_notes" name="txt_notes" onkeypress="vbs:Detect_Search_Field('txt_notes')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Mobile Number:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_mobileno" name="txt_mobileno" onkeypress="vbs:Detect_Search_Field('txt_mobileno')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Company:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_company" name="txt_company" onkeypress="vbs:Detect_Search_Field('txt_company')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Address:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_address" name="txt_address" onkeypress="vbs:Detect_Search_Field('txt_address')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          City:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_city" name="txt_city" onkeypress="vbs:Detect_Search_Field('txt_city')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          State:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_state" name="txt_state" onkeypress="vbs:Detect_Search_Field('txt_state')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Zip Code:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_zipcode" name="txt_zipcode" onkeypress="vbs:Detect_Search_Field('txt_zipcode')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Country:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_country" name="txt_country" onkeypress="vbs:Detect_Search_Field('txt_country')">
                                          &nbsp&nbspMust search by 2 letter country code
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Home Phone:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_homephone" name="txt_homephone" onkeypress="vbs:Detect_Search_Field('txt_homephone')">
                                    </td>
                              </tr>
                              <tr>
                                    <td colspan="2" align="center">
                                          <br>Showing record&nbsp
                                          <span id="span_currentrecord">
                                          0
                                          </span>
                                          &nbspof&nbsp
                                          <span id="span_totalrecords">
                                          0
                                          </span>
                                          <br>
                                          <input type='button' value='||< First' name='btnFirstEvent'  onClick='vbs:First_Event'>&nbsp&nbsp&nbsp&nbsp&nbsp
                                          <input type='button' value='<< Previous' name='btnPreviousEvent'  onClick='vbs:Previous_Event'>&nbsp&nbsp&nbsp&nbsp&nbsp
                                          <input type='button' value='Next >>' name='btnNextEvent'  onClick='vbs:Next_Event'>&nbsp&nbsp&nbsp&nbsp&nbsp
                                          <input type='button' value='Last >||' name='btnLastEvent'  onClick='vbs:Last_Event'><br><br><br>
                                          <input type='button' value='Clear Form' name='btnClearForm'  onClick='vbs:Clear_Form'>
                                          <input type="button" value="Submit" name="btn_submit" onClick="vbs:Submit_Form">
                                <input id=runbutton  class="button" type="button" value="Save to" name="run_button"  onClick="Runscript">
                                    </td>
                              </tr>
                        </table>
                  </td>
            </tr>
      </table>
 </body>

Open in new window

0
Comment
Question by:bsharath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 5
17 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 21766111
What about this.  If that's not correct.....what is exact format of your Notes field, including characters and spaces?

Rob.
<head>
<title>User Information</title>
<HTA:APPLICATION 
     APPLICATIONNAME="User Information"
     BORDER="thin"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
</head>
 
<script language="VBScript">
 
' Global variables
Dim arrRows
 
Sub Window_OnLoad
      intWidth = 800
      intHeight = 900
      Me.ResizeTo intWidth, intHeight
      Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
      btnFirstEvent.Disabled = True
      btnPreviousEvent.Disabled = True
      btnNextEvent.Disabled = True
      btnLastEvent.Disabled = True
      btnFirstEvent.Style.Visibility = "Hidden"
      btnPreviousEvent.Style.Visibility = "Hidden"
      btnNextEvent.Style.Visibility = "Hidden"
      btnLastEvent.Style.Visibility = "Hidden"
End Sub
 
Sub Default_Buttons
      If Window.Event.KeyCode = 13 Then
            btn_submit.Click
      ElseIf Window.Event.KeyCode = 27 Then
            Clear_Form
      End If      
End Sub
 
Sub Clear_Form
      txt_seatno.Value = ""
      txt_seatno.style.backgroundColor="#FFFFFF"
      txt_seatno.Disabled = False
      txt_extensionno.Value = ""
      txt_extensionno.style.backgroundColor="#FFFFFF"
      txt_extensionno.Disabled = False
      txt_empid.Value = ""
      txt_empid.style.backgroundColor="#FFFFFF"
      txt_empid.Disabled = False
      txt_department.Value = ""
      txt_department.style.backgroundColor="#FFFFFF"
      txt_department.Disabled = False
      txt_designation.Value = ""
      txt_designation.style.backgroundColor="#FFFFFF"
      txt_designation.Disabled = False
      txt_name.Value = ""
      txt_name.style.backgroundColor="#FFFFFF"
      txt_name.Disabled = False
      txt_loginname.Value = ""
      txt_loginname.style.backgroundColor="#FFFFFF"
      txt_loginname.Disabled = False
      txt_email.Value = ""
      txt_email.style.backgroundColor="#FFFFFF"
      txt_email.Disabled = False
      txt_notes.Value = ""
      txt_notes.style.backgroundColor="#FFFFFF"
      txt_notes.Disabled = False
      txt_mobileno.Value = ""
      txt_mobileno.style.backgroundColor="#FFFFFF"
      txt_mobileno.Disabled = False
      txt_company.Value = ""
      txt_company.style.backgroundColor="#FFFFFF"
      txt_company.Disabled = False
      txt_address.Value = ""
      txt_address.style.backgroundColor="#FFFFFF"
      txt_address.Disabled = False
      txt_city.Value = ""
      txt_city.style.backgroundColor="#FFFFFF"
      txt_city.Disabled = False
      txt_state.Value = ""
      txt_state.style.backgroundColor="#FFFFFF"
      txt_state.Disabled = False
      txt_zipcode.Value = ""
      txt_zipcode.style.backgroundColor="#FFFFFF"
      txt_zipcode.Disabled = False
      txt_country.Value = ""
      txt_country.style.backgroundColor="#FFFFFF"
      txt_country.Disabled = False
      txt_homephone.Value = ""
      txt_homephone.style.backgroundColor="#FFFFFF"
      txt_homephone.Disabled = False
      btnFirstEvent.Style.Visibility = "Hidden"
      btnPreviousEvent.Style.Visibility = "Hidden"
      btnNextEvent.Style.Visibility = "Hidden"
      btnLastEvent.Style.Visibility = "Hidden"
      span_currentrecord.InnerHTML = "0"
      span_totalrecords.InnerHTML = "0"
End Sub
 
Sub Submit_Form
 
      arrFields = Array(_
      		"txt_seatno", _
            "txt_extensionno", _
            "txt_empid", _
            "txt_department", _
            "txt_designation", _
            "txt_name", _
            "txt_loginname", _
            "txt_email", _
            "txt_notes", _
            "txt_mobileno", _
            "txt_company", _
            "txt_address", _
            "txt_city", _
            "txt_state", _
            "txt_zipcode", _
            "txt_country", _
            "txt_homephone" _
      )
      
      boolValid = False
      For Each strField In arrFields
            If Eval(strField & ".Disabled") = True Then
                  boolValid = True
            End If
            If Eval(strField & ".Disabled") = False Then
                  strCurrentField = strField
            End If
      Next
      
      If boolValid = False Then strCurrentField = "INVALID"
      
      Select Case strCurrentField
            Case "txt_seatno"
                  If txt_seatno.Value = "" Then
                              strSearchField = "(physicalDeliveryOfficeName=*)"
                        Else
                              strSearchField = "(physicalDeliveryOfficeName=*" & txt_seatno.Value & "*)"
                        End If
            Case "txt_extensionno"
                  If txt_extensionno.Value = "" Then
                        strSearchField = "(telephoneNumber=*)"
                  Else
                              strSearchField = "(telephoneNumber=*" & txt_extensionno.Value & "*)"
                        End If
            Case "txt_empid"
                  If txt_empid.Value = "" Then
                        strSearchField = "(description=*)"
                  Else
                              strSearchField = "(description=*" & txt_empid.Value & "*)"
                        End If
            Case "txt_department"
                  If txt_department.Value = "" Then
                        strSearchField = "(department=*)"
                  Else
                              strSearchField = "(department=*" & txt_department.Value & "*)"
                        End If
            Case "txt_designation"
                  If txt_designation.Value = "" Then
                        strSearchField = "(title=*)"
                  Else
                              strSearchField = "(title=*" & txt_designation.Value & "*)"
                        End If
            Case "txt_name"
                  If txt_name.Value = "" Then
                              strSearchField = "(cn=*)"
                        Else
                              strSearchField = "(cn=*" & txt_name.Value & "*)"
                        End If
            Case "txt_loginname"
                  If txt_loginname.Value = "" Then
                        strSearchField = "(samAccountName=*)"
                  Else
                              strSearchField = "(samAccountName=*" & txt_loginname.Value & "*)"
                        End If
            Case "txt_email"
                  If txt_email.Value = "" Then
                        strSearchField = "(mail=*)"
                  Else
                              strSearchField = "(mail=*" & txt_email.Value & "*)"
                        End If
            Case "txt_notes"
                  If txt_notes.Value = "" Then
                        strSearchField = "(info=*)"
                  Else
                              strSearchField = "(info=*" & txt_notes.Value & "*)"
                        End If
            Case "txt_mobileno"
                  If txt_mobileno.Value = "" Then
                        strSearchField = "(mobile=*)"
                  Else
                              strSearchField = "(mobile=*" & txt_mobileno.Value & "*)"
                        End If
            Case "txt_company"
                  If txt_company.Value = "" Then
                        strSearchField = "(company=*)"
                  Else
                              strSearchField = "(company=*" & txt_company.Value & "*)"
                        End If
            Case "txt_address"
                  If txt_address.Value = "" Then
                        strSearchField = "(streetAddress=*)"
                  Else
                              strSearchField = "(streetAddress=*" & txt_address.Value & "*)"
                        End If
            Case "txt_city"
                  If txt_city.Value = "" Then
                        strSearchField = "(l=*)"
                  Else
                              strSearchField = "(l=*" & txt_city.Value & "*)"
                        End If
            Case "txt_state"
                  If txt_state.Value = "" Then
                        strSearchField = "(st=*)"
                  Else
                              strSearchField = "(st=*" & txt_state.Value & "*)"
                        End If
            Case "txt_zipcode"
                  If txt_zipcode.Value = "" Then
                        strSearchField = "(postalCode=*)"
                  Else
                              strSearchField = "(postalCode=*" & txt_zipcode.Value & "*)"
                        End If
            Case "txt_country"
                  If txt_country.Value = "" Then
                        strSearchField = "(c=*)"
                  Else
                              strSearchField = "(c=*" & txt_country.Value & "*)"
                        End If
            Case "txt_homephone"
                  If txt_homephone.Value = "" Then
                        strSearchField = "(homePhone=*)"
                  Else
                              strSearchField = "(homePhone=*" & txt_homephone.Value & "*)"
                        End If
            Case Else
                  strSearchField = "INVALID"
      End Select
 
      Clear_Form
      
      If strSearchField <> "INVALID" Then
            Set adoCommand = CreateObject("ADODB.Command")
            Set adoConnection = CreateObject("ADODB.Connection")
            adoConnection.Provider = "ADsDSOObject"
            adoConnection.Open "Active Directory Provider"
            adoCommand.ActiveConnection = adoConnection
            
             ' Search entire Active Directory domain.
            Set objRootDSE = GetObject("LDAP://RootDSE")
            
            strDNSDomain = objRootDSE.Get("defaultNamingContext")
            strBase = "<LDAP://" & strDNSDomain & ">"
            
            strFilter = "(&(objectCategory=person)(objectClass=user)" & strSearchField & ")"
            'strFilter = "(&(objectClass=computer)(cn=" & strComputer & "))"
            
            ' Comma delimited list of attribute values to retrieve.
            strAttributes = "physicalDeliveryOfficeName,TelephoneNumber,description,Department,Title,cn,samAccountName,mail,Info,Mobile,company,streetAddress,l,st,postalCode,c,homePhone"
            
            ' Construct the LDAP syntax query.
            strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
            adoCommand.CommandText = strQuery
            adoCommand.Properties("Page Size") = 100
            adoCommand.Properties("Timeout") = 30
            adoCommand.Properties("Cache Results") = False
 
            ' Run the query.
            Set adoRecordset = adoCommand.Execute
             
            ' Enumerate the resulting recordset.
            strDetails = ""
            If Not adoRecordset.EOF Then
                  Do Until adoRecordset.EOF
                        If strDetails = "" Then
                              strDetails = adoRecordset.Fields("physicalDeliveryOfficeName").Value &_
                                                "|TD|" & adoRecordset.Fields("TelephoneNumber").Value
                                                If IsNull(adoRecordset.Fields("Description").Value) = False Then
                                                      strDetails = strDetails & "|TD|" & Join(adoRecordset.Fields("description").Value)
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Title").Value &_
                                                "|TD|" & adoRecordset.Fields("Department").Value &_
                              					"|TD|" & Replace(adoRecordset.Fields("cn").Value, "CN=", "") &_
                                                "|TD|" & adoRecordset.Fields("samAccountName").Value &_
                                                "|TD|" & adoRecordset.Fields("mail").Value
                                                If IsNull(adoRecordset.Fields("Info").Value) = False Then
                                                      strDetails = strDetails & "|TD|" & Replace(adoRecordset.Fields("Info").Value, "Machine Name : ", "")
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Mobile").Value &_
                                                "|TD|" & adoRecordset.Fields("company").Value &_
                                                "|TD|" & adoRecordset.Fields("streetAddress").Value &_
                                                "|TD|" & adoRecordset.Fields("l").Value &_
                                                "|TD|" & adoRecordset.Fields("st").Value &_
                                                "|TD|" & adoRecordset.Fields("postalCode").Value &_
                                                "|TD|" & adoRecordset.Fields("c").Value &_
                                                "|TD|" & adoRecordset.Fields("homePhone").Value
                        Else
                              strDetails = strDetails & "|TR|" & adoRecordset.Fields("physicalDeliveryOfficeName").Value &_
                                                "|TD|" & adoRecordset.Fields("TelephoneNumber").Value
                                                If IsNull(adoRecordset.Fields("Description").Value) = False Then
                                                      strDetails = strDetails & "|TD|" & Join(adoRecordset.Fields("description").Value)
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Title").Value &_
                                                "|TD|" & adoRecordset.Fields("Department").Value &_
                              					"|TD|" & Replace(adoRecordset.Fields("cn").Value, "CN=", "") &_
                                                "|TD|" & adoRecordset.Fields("samAccountName").Value &_
                                                "|TD|" & adoRecordset.Fields("mail").Value
                                                If IsNull(adoRecordset.Fields("Info").Value) = False Then
                                                      strDetails = strDetails & "|TD|" & Replace(adoRecordset.Fields("Info").Value, "Machine Name : ", "")
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Mobile").Value &_
                                                "|TD|" & adoRecordset.Fields("company").Value &_
                                                "|TD|" & adoRecordset.Fields("streetAddress").Value &_
                                                "|TD|" & adoRecordset.Fields("l").Value &_
                                                "|TD|" & adoRecordset.Fields("st").Value &_
                                                "|TD|" & adoRecordset.Fields("postalCode").Value &_
                                                "|TD|" & adoRecordset.Fields("c").Value &_
                                                "|TD|" & adoRecordset.Fields("homePhone").Value
                        End If
                      adoRecordset.MoveNext
                  Loop
            Else
                  MsgBox "No records were found"
            End If
            
            ' Clean up.
            adoRecordset.Close
            Set adoRecordset = Nothing
            
            adoConnection.Close
      
            If strDetails <> "" Then
                  arrRows = ""
                  arrRows = Split(strDetails, "|TR|")
                  If UBound(arrRows) < 0 Then
                        span_currentrecord.InnerHTML = "0"
                        span_totalrecords.InnerHTML = "0"
                  Else
                        arrData = Split(arrRows(0), "|TD|")
						txt_seatno.Value = arrData(0)
                        txt_extensionno.Value = arrData(1)
                        txt_empid.Value = arrData(2)
                        txt_department.Value = arrData(3)
                        txt_designation.Value = arrData(4)
                        txt_name.Value = arrData(5)
                        txt_loginname.Value = arrData(6)
                        txt_email.Value = arrData(7)
                        txt_notes.Value = arrData(8)
                        txt_mobileno.Value = arrData(9)
                        txt_company.Value = arrData(10)
                        txt_address.Value = arrData(11)
                        txt_city.Value = arrData(12)
                        txt_state.Value = arrData(13)
                        txt_zipcode.Value = arrData(14)
                        txt_country.Value = arrData(15)
                        txt_homephone.Value = arrData(16)
                        span_currentrecord.InnerHTML = "1"
                        span_totalrecords.InnerHTML = UBound(arrRows) + 1
                  End If
            Else
                  span_currentrecord.InnerHTML = "0"
                  span_totalrecords.InnerHTML = "0"
            End If
            If strDetails = "" Then
                  btnFirstEvent.Disabled = True
                  btnPreviousEvent.Disabled = True
                  btnNextEvent.Disabled = True
                  btnLastEvent.Disabled = True      
                  btnFirstEvent.Style.Visibility = "Hidden"
                  btnPreviousEvent.Style.Visibility = "Hidden"
                  btnNextEvent.Style.Visibility = "Hidden"
                  btnLastEvent.Style.Visibility = "Hidden"
            ElseIf UBound(arrRows) = 0 Then
                  btnFirstEvent.Disabled = True
                  btnPreviousEvent.Disabled = True
                  btnNextEvent.Disabled = True
                  btnLastEvent.Disabled = True
                  btnFirstEvent.Style.Visibility = "Hidden"
                  btnPreviousEvent.Style.Visibility = "Hidden"
                  btnNextEvent.Style.Visibility = "Hidden"
                  btnLastEvent.Style.Visibility = "Hidden"
            Else
                  btnFirstEvent.Disabled = False
                  btnPreviousEvent.Disabled = False
                  btnNextEvent.Disabled = False
                  btnLastEvent.Disabled = False
                  btnFirstEvent.Style.Visibility = "Visible"
                  btnPreviousEvent.Style.Visibility = "Visible"
                  btnNextEvent.Style.Visibility = "Visible"
                  btnLastEvent.Style.Visibility = "Visible"
            End If
      Else
            MsgBox "Please type a search request into one of the fields, then click Submit."
      End If
      
End Sub
 
Sub Get_Event
 
	arrData = Split(arrRows(span_currentrecord.InnerHTML - 1), "|TD|")
	txt_seatno.Value = arrData(0)
	txt_extensionno.Value = arrData(1)
	txt_empid.Value = arrData(2)
	txt_department.Value = arrData(3)
	txt_designation.Value = arrData(4)
	txt_name.Value = arrData(5)
	txt_loginname.Value = arrData(6)
	txt_email.Value = arrData(7)
	txt_notes.Value = arrData(8)
	txt_mobileno.Value = arrData(9)
	txt_company.Value = arrData(10)
	txt_address.Value = arrData(11)
	txt_city.Value = arrData(12)
	txt_state.Value = arrData(13)
	txt_zipcode.Value = arrData(14)
	txt_country.Value = arrData(15)
	txt_homephone.Value = arrData(16)
 
End Sub
 
Sub First_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_totalrecords.InnerHTML < 1 Then
                  MsgBox "There are no records to display"
            ElseIf span_currentrecord.InnerHTML = 1 Then
                  MsgBox "You are already viewing the first record."
            Else
                  span_currentrecord.InnerHTML = 1
                  Get_Event
            End If
      End If
      
End Sub
 
Sub Previous_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_currentrecord.InnerHTML > 1 Then
                  span_currentrecord.InnerHTML = span_currentrecord.InnerHTML - 1
                  Get_Event
            ElseIf span_currentrecord.InnerHTML = 1 Then
                        MsgBox "You are already viewing the first record."
            Else
                  MsgBox "There are no records to display"
            End If
      End If
 
End Sub
 
Sub Next_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_totalrecords.InnerHTML = 0 Then
                  MsgBox "There are no records for to display"
            ElseIf span_currentrecord.InnerHTML = span_totalrecords.InnerHTML Then
                  MsgBox "You are already viewing the last record."
            Else
                  span_currentrecord.InnerHTML = span_currentrecord.InnerHTML + 1
                  Get_Event
            End If
      End If
      
End Sub
 
Sub Last_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_totalrecords.InnerHTML = 0 Then
                  MsgBox "There are no records to display"
            ElseIf span_currentrecord.InnerHTML = span_totalrecords.InnerHTML Then
                        MsgBox "You are already viewing the last record."
            Else
                  span_currentrecord.InnerHTML = span_totalrecords.InnerHTML
                  Get_Event
            End If
      End If
      
End Sub
 
Sub Detect_Search_Field(strCurrentField)
      arrFields = Array(_
      		"txt_seatno", _
            "txt_extensionno", _
            "txt_empid", _
            "txt_department", _
            "txt_designation", _
            "txt_name", _
            "txt_loginname", _
            "txt_email", _
            "txt_notes", _
            "txt_mobileno", _
            "txt_company", _
            "txt_address", _
            "txt_city", _
            "txt_state", _
            "txt_zipcode", _
            "txt_country", _
            "txt_homephone" _
      )
      
      For Each strField In arrFields
            If LCase(strField) <> LCase(strCurrentField) Then
                  Execute strField & ".style.backgroundColor=""#D3D3D3"""
                  Execute strField & ".Disabled = True"
            End If
      Next
End Sub
 
Sub RunScript
      strAnswer = window.prompt("Please enter the Location to save.", "C:\HTAResults.csv")
 
      If IsNull(strAnswer) Then
            Msgbox "You clicked the Cancel button"
      Else
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            If objFSO.FileExists(strAnswer) = True Then
                  Set objFile = objFSO.OpenTextFile(strAnswer, 8, False)
            Else
                  Set objFile = objFSO.CreateTextFile(strAnswer, True)
                  objFile.Write """Seat No"",""Extension"",""Emp ID"",""Department"",""Designation"",""User Name"",""Login Name"",""Email Address"",""Computer"",""Mobile"",""Company"",""Address"",""City"",""State"",""Zip Code"",""Country"",""Home Phone"""
            End If
      
                  For intRow = LBound(arrRows) To UBound(arrRows)
                        arrData = Split(arrRows(intRow), "|TD|")
                  objFile.Write VbCrLf & """" & arrData(0) & """,""" & arrData(1) & """,""" & arrData(2) & """,""" & arrData(3) & _
                        """,""" & arrData(4) & """,""" & arrData(5) & """,""" & arrData(6) & """,""" & arrData(7) & _
                        """,""" & arrData(8) & """,""" & arrData(9) & """,""" & arrData(10) & """,""" & arrData(11) & _
                        """,""" & arrData(12) & """,""" & arrData(13) & """,""" & arrData(14) & """,""" & arrData(15) & _
                        """,""" & arrData(16) & """"
                  Next
            objFile.Close
            MsgBox "Saved."
      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><tr><td align='right'><img src='G:\Tools\oemlogo.bmp'></td></tr></table>     
 <table width='90%' height = '100%' align='center' border='0'>
            <tr>
                  <td align='center' colspan="2">
                        <h3>User Information</h3><br>
                  </td>
            </tr
            <tr>
                  <td align='center' colspan="2">
                        <table border="0">
                              <tr>
                                    <td>
                                          Seat No:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_seatno" name="txt_seatno" onkeypress="vbs:Detect_Search_Field('txt_seatno')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Extension No:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="25" size="40" id="txt_extensionno" name="txt_extensionno" onkeypress="vbs:Detect_Search_Field('txt_extensionno')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Emp ID:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="6" size="10" id="txt_empid" name="txt_empid" onkeypress="vbs:Detect_Search_Field('txt_empid')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Department:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="50" id="txt_department" name="txt_department" onkeypress="vbs:Detect_Search_Field('txt_department')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Designation:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="50" size="70" id="txt_designation" name="txt_designation" onkeypress="vbs:Detect_Search_Field('txt_designation')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          User Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_name" name="txt_name" onkeypress="vbs:Detect_Search_Field('txt_name')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Login Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_loginname" name="txt_loginname" onkeypress="vbs:Detect_Search_Field('txt_loginname')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Email Address:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="50" size="70" id="txt_email" name="txt_email" onkeypress="vbs:Detect_Search_Field('txt_email')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                         Machine Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="16" size="20" id="txt_notes" name="txt_notes" onkeypress="vbs:Detect_Search_Field('txt_notes')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Mobile Number:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_mobileno" name="txt_mobileno" onkeypress="vbs:Detect_Search_Field('txt_mobileno')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Company:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_company" name="txt_company" onkeypress="vbs:Detect_Search_Field('txt_company')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Address:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_address" name="txt_address" onkeypress="vbs:Detect_Search_Field('txt_address')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          City:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_city" name="txt_city" onkeypress="vbs:Detect_Search_Field('txt_city')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          State:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_state" name="txt_state" onkeypress="vbs:Detect_Search_Field('txt_state')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Zip Code:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_zipcode" name="txt_zipcode" onkeypress="vbs:Detect_Search_Field('txt_zipcode')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Country:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_country" name="txt_country" onkeypress="vbs:Detect_Search_Field('txt_country')">
                                          &nbsp&nbspMust search by 2 letter country code
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Home Phone:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_homephone" name="txt_homephone" onkeypress="vbs:Detect_Search_Field('txt_homephone')">
                                    </td>
                              </tr>
                              <tr>
                                    <td colspan="2" align="center">
                                          <br>Showing record&nbsp
                                          <span id="span_currentrecord">
                                          0
                                          </span>
                                          &nbspof&nbsp
                                          <span id="span_totalrecords">
                                          0
                                          </span>
                                          <br>
                                          <input type='button' value='||< First' name='btnFirstEvent'  onClick='vbs:First_Event'>&nbsp&nbsp&nbsp&nbsp&nbsp
                                          <input type='button' value='<< Previous' name='btnPreviousEvent'  onClick='vbs:Previous_Event'>&nbsp&nbsp&nbsp&nbsp&nbsp
                                          <input type='button' value='Next >>' name='btnNextEvent'  onClick='vbs:Next_Event'>&nbsp&nbsp&nbsp&nbsp&nbsp
                                          <input type='button' value='Last >||' name='btnLastEvent'  onClick='vbs:Last_Event'><br><br><br>
                                          <input type='button' value='Clear Form' name='btnClearForm'  onClick='vbs:Clear_Form'>
                                          <input type="button" value="Submit" name="btn_submit" onClick="vbs:Submit_Form">
                                <input id=runbutton  class="button" type="button" value="Save to" name="run_button"  onClick="Runscript">
                                    </td>
                              </tr>
                        </table>
                  </td>
            </tr>
      </table>
 </body>

Open in new window

0
 
LVL 11

Author Comment

by:bsharath
ID: 21766131
Format is like this

MACHINE NAME :
Still i get the result as
MACHINE NAME :  dev-chen-9022
i need to remove the " MACHINE NAME : " when it shows up.
0
 
LVL 11

Author Comment

by:bsharath
ID: 21766133
Format is like this

MACHINE NAME :
Still i get the result as
MACHINE NAME :  dev-chen-9022
i need to remove the " MACHINE NAME : " when it shows up.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Author Comment

by:bsharath
ID: 21766145
Rob in this hta is the department  linked to designation and designation linked to department.
As the headers show different than the output.
0
 
LVL 11

Author Comment

by:bsharath
ID: 21766146
Rob in this hta is the department  linked to designation and designation linked to department.
As the headers show different than the output.
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 21766748
This will fix the department and designation mix up....

It is removing the "Machine Name" part, on the assumption that it is
Machine Name<space>:<space><computer name>

I have changed that to be case insensitive...maybe that was the problem....

Regards,

Rob.
<head>
<title>User Information</title>
<HTA:APPLICATION 
     APPLICATIONNAME="User Information"
     BORDER="thin"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
</head>
 
<script language="VBScript">
 
' Global variables
Dim arrRows
 
Sub Window_OnLoad
      intWidth = 800
      intHeight = 900
      Me.ResizeTo intWidth, intHeight
      Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
      btnFirstEvent.Disabled = True
      btnPreviousEvent.Disabled = True
      btnNextEvent.Disabled = True
      btnLastEvent.Disabled = True
      btnFirstEvent.Style.Visibility = "Hidden"
      btnPreviousEvent.Style.Visibility = "Hidden"
      btnNextEvent.Style.Visibility = "Hidden"
      btnLastEvent.Style.Visibility = "Hidden"
End Sub
 
Sub Default_Buttons
      If Window.Event.KeyCode = 13 Then
            btn_submit.Click
      ElseIf Window.Event.KeyCode = 27 Then
            Clear_Form
      End If      
End Sub
 
Sub Clear_Form
      txt_seatno.Value = ""
      txt_seatno.style.backgroundColor="#FFFFFF"
      txt_seatno.Disabled = False
      txt_extensionno.Value = ""
      txt_extensionno.style.backgroundColor="#FFFFFF"
      txt_extensionno.Disabled = False
      txt_empid.Value = ""
      txt_empid.style.backgroundColor="#FFFFFF"
      txt_empid.Disabled = False
      txt_department.Value = ""
      txt_department.style.backgroundColor="#FFFFFF"
      txt_department.Disabled = False
      txt_designation.Value = ""
      txt_designation.style.backgroundColor="#FFFFFF"
      txt_designation.Disabled = False
      txt_name.Value = ""
      txt_name.style.backgroundColor="#FFFFFF"
      txt_name.Disabled = False
      txt_loginname.Value = ""
      txt_loginname.style.backgroundColor="#FFFFFF"
      txt_loginname.Disabled = False
      txt_email.Value = ""
      txt_email.style.backgroundColor="#FFFFFF"
      txt_email.Disabled = False
      txt_notes.Value = ""
      txt_notes.style.backgroundColor="#FFFFFF"
      txt_notes.Disabled = False
      txt_mobileno.Value = ""
      txt_mobileno.style.backgroundColor="#FFFFFF"
      txt_mobileno.Disabled = False
      txt_company.Value = ""
      txt_company.style.backgroundColor="#FFFFFF"
      txt_company.Disabled = False
      txt_address.Value = ""
      txt_address.style.backgroundColor="#FFFFFF"
      txt_address.Disabled = False
      txt_city.Value = ""
      txt_city.style.backgroundColor="#FFFFFF"
      txt_city.Disabled = False
      txt_state.Value = ""
      txt_state.style.backgroundColor="#FFFFFF"
      txt_state.Disabled = False
      txt_zipcode.Value = ""
      txt_zipcode.style.backgroundColor="#FFFFFF"
      txt_zipcode.Disabled = False
      txt_country.Value = ""
      txt_country.style.backgroundColor="#FFFFFF"
      txt_country.Disabled = False
      txt_homephone.Value = ""
      txt_homephone.style.backgroundColor="#FFFFFF"
      txt_homephone.Disabled = False
      btnFirstEvent.Style.Visibility = "Hidden"
      btnPreviousEvent.Style.Visibility = "Hidden"
      btnNextEvent.Style.Visibility = "Hidden"
      btnLastEvent.Style.Visibility = "Hidden"
      span_currentrecord.InnerHTML = "0"
      span_totalrecords.InnerHTML = "0"
End Sub
 
Sub Submit_Form
 
      arrFields = Array(_
      		"txt_seatno", _
            "txt_extensionno", _
            "txt_empid", _
            "txt_department", _
            "txt_designation", _
            "txt_name", _
            "txt_loginname", _
            "txt_email", _
            "txt_notes", _
            "txt_mobileno", _
            "txt_company", _
            "txt_address", _
            "txt_city", _
            "txt_state", _
            "txt_zipcode", _
            "txt_country", _
            "txt_homephone" _
      )
      
      boolValid = False
      For Each strField In arrFields
            If Eval(strField & ".Disabled") = True Then
                  boolValid = True
            End If
            If Eval(strField & ".Disabled") = False Then
                  strCurrentField = strField
            End If
      Next
      
      If boolValid = False Then strCurrentField = "INVALID"
      
      Select Case strCurrentField
            Case "txt_seatno"
                  If txt_seatno.Value = "" Then
                              strSearchField = "(physicalDeliveryOfficeName=*)"
                        Else
                              strSearchField = "(physicalDeliveryOfficeName=*" & txt_seatno.Value & "*)"
                        End If
            Case "txt_extensionno"
                  If txt_extensionno.Value = "" Then
                        strSearchField = "(telephoneNumber=*)"
                  Else
                              strSearchField = "(telephoneNumber=*" & txt_extensionno.Value & "*)"
                        End If
            Case "txt_empid"
                  If txt_empid.Value = "" Then
                        strSearchField = "(description=*)"
                  Else
                              strSearchField = "(description=*" & txt_empid.Value & "*)"
                        End If
            Case "txt_department"
                  If txt_department.Value = "" Then
                        strSearchField = "(department=*)"
                  Else
                              strSearchField = "(department=*" & txt_department.Value & "*)"
                        End If
            Case "txt_designation"
                  If txt_designation.Value = "" Then
                        strSearchField = "(title=*)"
                  Else
                              strSearchField = "(title=*" & txt_designation.Value & "*)"
                        End If
            Case "txt_name"
                  If txt_name.Value = "" Then
                              strSearchField = "(cn=*)"
                        Else
                              strSearchField = "(cn=*" & txt_name.Value & "*)"
                        End If
            Case "txt_loginname"
                  If txt_loginname.Value = "" Then
                        strSearchField = "(samAccountName=*)"
                  Else
                              strSearchField = "(samAccountName=*" & txt_loginname.Value & "*)"
                        End If
            Case "txt_email"
                  If txt_email.Value = "" Then
                        strSearchField = "(mail=*)"
                  Else
                              strSearchField = "(mail=*" & txt_email.Value & "*)"
                        End If
            Case "txt_notes"
                  If txt_notes.Value = "" Then
                        strSearchField = "(info=*)"
                  Else
                              strSearchField = "(info=*" & txt_notes.Value & "*)"
                        End If
            Case "txt_mobileno"
                  If txt_mobileno.Value = "" Then
                        strSearchField = "(mobile=*)"
                  Else
                              strSearchField = "(mobile=*" & txt_mobileno.Value & "*)"
                        End If
            Case "txt_company"
                  If txt_company.Value = "" Then
                        strSearchField = "(company=*)"
                  Else
                              strSearchField = "(company=*" & txt_company.Value & "*)"
                        End If
            Case "txt_address"
                  If txt_address.Value = "" Then
                        strSearchField = "(streetAddress=*)"
                  Else
                              strSearchField = "(streetAddress=*" & txt_address.Value & "*)"
                        End If
            Case "txt_city"
                  If txt_city.Value = "" Then
                        strSearchField = "(l=*)"
                  Else
                              strSearchField = "(l=*" & txt_city.Value & "*)"
                        End If
            Case "txt_state"
                  If txt_state.Value = "" Then
                        strSearchField = "(st=*)"
                  Else
                              strSearchField = "(st=*" & txt_state.Value & "*)"
                        End If
            Case "txt_zipcode"
                  If txt_zipcode.Value = "" Then
                        strSearchField = "(postalCode=*)"
                  Else
                              strSearchField = "(postalCode=*" & txt_zipcode.Value & "*)"
                        End If
            Case "txt_country"
                  If txt_country.Value = "" Then
                        strSearchField = "(c=*)"
                  Else
                              strSearchField = "(c=*" & txt_country.Value & "*)"
                        End If
            Case "txt_homephone"
                  If txt_homephone.Value = "" Then
                        strSearchField = "(homePhone=*)"
                  Else
                              strSearchField = "(homePhone=*" & txt_homephone.Value & "*)"
                        End If
            Case Else
                  strSearchField = "INVALID"
      End Select
 
      Clear_Form
      
      If strSearchField <> "INVALID" Then
            Set adoCommand = CreateObject("ADODB.Command")
            Set adoConnection = CreateObject("ADODB.Connection")
            adoConnection.Provider = "ADsDSOObject"
            adoConnection.Open "Active Directory Provider"
            adoCommand.ActiveConnection = adoConnection
            
             ' Search entire Active Directory domain.
            Set objRootDSE = GetObject("LDAP://RootDSE")
            
            strDNSDomain = objRootDSE.Get("defaultNamingContext")
            strBase = "<LDAP://" & strDNSDomain & ">"
            
            strFilter = "(&(objectCategory=person)(objectClass=user)" & strSearchField & ")"
            'strFilter = "(&(objectClass=computer)(cn=" & strComputer & "))"
            
            ' Comma delimited list of attribute values to retrieve.
            strAttributes = "physicalDeliveryOfficeName,TelephoneNumber,description,Department,Title,cn,samAccountName,mail,Info,Mobile,company,streetAddress,l,st,postalCode,c,homePhone"
            
            ' Construct the LDAP syntax query.
            strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
            adoCommand.CommandText = strQuery
            adoCommand.Properties("Page Size") = 100
            adoCommand.Properties("Timeout") = 30
            adoCommand.Properties("Cache Results") = False
 
            ' Run the query.
            Set adoRecordset = adoCommand.Execute
             
            ' Enumerate the resulting recordset.
            strDetails = ""
            If Not adoRecordset.EOF Then
                  Do Until adoRecordset.EOF
                        If strDetails = "" Then
                              strDetails = adoRecordset.Fields("physicalDeliveryOfficeName").Value &_
                                                "|TD|" & adoRecordset.Fields("TelephoneNumber").Value
                                                If IsNull(adoRecordset.Fields("Description").Value) = False Then
                                                      strDetails = strDetails & "|TD|" & Join(adoRecordset.Fields("description").Value)
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Department").Value &_
                                                "|TD|" & adoRecordset.Fields("Title").Value &_
                              					"|TD|" & Replace(adoRecordset.Fields("cn").Value, "CN=", "") &_
                                                "|TD|" & adoRecordset.Fields("samAccountName").Value &_
                                                "|TD|" & adoRecordset.Fields("mail").Value
                                                If IsNull(adoRecordset.Fields("Info").Value) = False Then
                                                      If Left(LCase(adoRecordset.Fields("Info").Value), 15) = LCase("Machine Name : ") Then
                                                      	strInfo = Trim(Mid(adoRecordset.Fields("Info").Value, 15))
                                                      Else
                                                      	strInfo = adoRecordset.Fields("Info").Value
                                                      End If
                                                      strDetails = strDetails & "|TD|" & strInfo
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Mobile").Value &_
                                                "|TD|" & adoRecordset.Fields("company").Value &_
                                                "|TD|" & adoRecordset.Fields("streetAddress").Value &_
                                                "|TD|" & adoRecordset.Fields("l").Value &_
                                                "|TD|" & adoRecordset.Fields("st").Value &_
                                                "|TD|" & adoRecordset.Fields("postalCode").Value &_
                                                "|TD|" & adoRecordset.Fields("c").Value &_
                                                "|TD|" & adoRecordset.Fields("homePhone").Value
                        Else
                              strDetails = strDetails & "|TR|" & adoRecordset.Fields("physicalDeliveryOfficeName").Value &_
                                                "|TD|" & adoRecordset.Fields("TelephoneNumber").Value
                                                If IsNull(adoRecordset.Fields("Description").Value) = False Then
                                                      strDetails = strDetails & "|TD|" & Join(adoRecordset.Fields("description").Value)
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Title").Value &_
                                                "|TD|" & adoRecordset.Fields("Department").Value &_
                              					"|TD|" & Replace(adoRecordset.Fields("cn").Value, "CN=", "") &_
                                                "|TD|" & adoRecordset.Fields("samAccountName").Value &_
                                                "|TD|" & adoRecordset.Fields("mail").Value
                                                If IsNull(adoRecordset.Fields("Info").Value) = False Then
                                                      If Left(LCase(adoRecordset.Fields("Info").Value), 15) = LCase("Machine Name : ") Then
                                                      	strInfo = Trim(Mid(adoRecordset.Fields("Info").Value, 15))
                                                      Else
                                                      	strInfo = adoRecordset.Fields("Info").Value
                                                      End If
                                                      strDetails = strDetails & "|TD|" & strInfo
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Mobile").Value &_
                                                "|TD|" & adoRecordset.Fields("company").Value &_
                                                "|TD|" & adoRecordset.Fields("streetAddress").Value &_
                                                "|TD|" & adoRecordset.Fields("l").Value &_
                                                "|TD|" & adoRecordset.Fields("st").Value &_
                                                "|TD|" & adoRecordset.Fields("postalCode").Value &_
                                                "|TD|" & adoRecordset.Fields("c").Value &_
                                                "|TD|" & adoRecordset.Fields("homePhone").Value
                        End If
                      adoRecordset.MoveNext
                  Loop
            Else
                  MsgBox "No records were found"
            End If
            
            ' Clean up.
            adoRecordset.Close
            Set adoRecordset = Nothing
            
            adoConnection.Close
      
            If strDetails <> "" Then
                  arrRows = ""
                  arrRows = Split(strDetails, "|TR|")
                  If UBound(arrRows) < 0 Then
                        span_currentrecord.InnerHTML = "0"
                        span_totalrecords.InnerHTML = "0"
                  Else
                        arrData = Split(arrRows(0), "|TD|")
						txt_seatno.Value = arrData(0)
                        txt_extensionno.Value = arrData(1)
                        txt_empid.Value = arrData(2)
                        txt_department.Value = arrData(3)
                        txt_designation.Value = arrData(4)
                        txt_name.Value = arrData(5)
                        txt_loginname.Value = arrData(6)
                        txt_email.Value = arrData(7)
                        txt_notes.Value = arrData(8)
                        txt_mobileno.Value = arrData(9)
                        txt_company.Value = arrData(10)
                        txt_address.Value = arrData(11)
                        txt_city.Value = arrData(12)
                        txt_state.Value = arrData(13)
                        txt_zipcode.Value = arrData(14)
                        txt_country.Value = arrData(15)
                        txt_homephone.Value = arrData(16)
                        span_currentrecord.InnerHTML = "1"
                        span_totalrecords.InnerHTML = UBound(arrRows) + 1
                  End If
            Else
                  span_currentrecord.InnerHTML = "0"
                  span_totalrecords.InnerHTML = "0"
            End If
            If strDetails = "" Then
                  btnFirstEvent.Disabled = True
                  btnPreviousEvent.Disabled = True
                  btnNextEvent.Disabled = True
                  btnLastEvent.Disabled = True      
                  btnFirstEvent.Style.Visibility = "Hidden"
                  btnPreviousEvent.Style.Visibility = "Hidden"
                  btnNextEvent.Style.Visibility = "Hidden"
                  btnLastEvent.Style.Visibility = "Hidden"
            ElseIf UBound(arrRows) = 0 Then
                  btnFirstEvent.Disabled = True
                  btnPreviousEvent.Disabled = True
                  btnNextEvent.Disabled = True
                  btnLastEvent.Disabled = True
                  btnFirstEvent.Style.Visibility = "Hidden"
                  btnPreviousEvent.Style.Visibility = "Hidden"
                  btnNextEvent.Style.Visibility = "Hidden"
                  btnLastEvent.Style.Visibility = "Hidden"
            Else
                  btnFirstEvent.Disabled = False
                  btnPreviousEvent.Disabled = False
                  btnNextEvent.Disabled = False
                  btnLastEvent.Disabled = False
                  btnFirstEvent.Style.Visibility = "Visible"
                  btnPreviousEvent.Style.Visibility = "Visible"
                  btnNextEvent.Style.Visibility = "Visible"
                  btnLastEvent.Style.Visibility = "Visible"
            End If
      Else
            MsgBox "Please type a search request into one of the fields, then click Submit."
      End If
      
End Sub
 
Sub Get_Event
 
	arrData = Split(arrRows(span_currentrecord.InnerHTML - 1), "|TD|")
	txt_seatno.Value = arrData(0)
	txt_extensionno.Value = arrData(1)
	txt_empid.Value = arrData(2)
	txt_department.Value = arrData(3)
	txt_designation.Value = arrData(4)
	txt_name.Value = arrData(5)
	txt_loginname.Value = arrData(6)
	txt_email.Value = arrData(7)
	txt_notes.Value = arrData(8)
	txt_mobileno.Value = arrData(9)
	txt_company.Value = arrData(10)
	txt_address.Value = arrData(11)
	txt_city.Value = arrData(12)
	txt_state.Value = arrData(13)
	txt_zipcode.Value = arrData(14)
	txt_country.Value = arrData(15)
	txt_homephone.Value = arrData(16)
 
End Sub
 
Sub First_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_totalrecords.InnerHTML < 1 Then
                  MsgBox "There are no records to display"
            ElseIf span_currentrecord.InnerHTML = 1 Then
                  MsgBox "You are already viewing the first record."
            Else
                  span_currentrecord.InnerHTML = 1
                  Get_Event
            End If
      End If
      
End Sub
 
Sub Previous_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_currentrecord.InnerHTML > 1 Then
                  span_currentrecord.InnerHTML = span_currentrecord.InnerHTML - 1
                  Get_Event
            ElseIf span_currentrecord.InnerHTML = 1 Then
                        MsgBox "You are already viewing the first record."
            Else
                  MsgBox "There are no records to display"
            End If
      End If
 
End Sub
 
Sub Next_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_totalrecords.InnerHTML = 0 Then
                  MsgBox "There are no records for to display"
            ElseIf span_currentrecord.InnerHTML = span_totalrecords.InnerHTML Then
                  MsgBox "You are already viewing the last record."
            Else
                  span_currentrecord.InnerHTML = span_currentrecord.InnerHTML + 1
                  Get_Event
            End If
      End If
      
End Sub
 
Sub Last_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_totalrecords.InnerHTML = 0 Then
                  MsgBox "There are no records to display"
            ElseIf span_currentrecord.InnerHTML = span_totalrecords.InnerHTML Then
                        MsgBox "You are already viewing the last record."
            Else
                  span_currentrecord.InnerHTML = span_totalrecords.InnerHTML
                  Get_Event
            End If
      End If
      
End Sub
 
Sub Detect_Search_Field(strCurrentField)
      arrFields = Array(_
      		"txt_seatno", _
            "txt_extensionno", _
            "txt_empid", _
            "txt_department", _
            "txt_designation", _
            "txt_name", _
            "txt_loginname", _
            "txt_email", _
            "txt_notes", _
            "txt_mobileno", _
            "txt_company", _
            "txt_address", _
            "txt_city", _
            "txt_state", _
            "txt_zipcode", _
            "txt_country", _
            "txt_homephone" _
      )
      
      For Each strField In arrFields
            If LCase(strField) <> LCase(strCurrentField) Then
                  Execute strField & ".style.backgroundColor=""#D3D3D3"""
                  Execute strField & ".Disabled = True"
            End If
      Next
End Sub
 
Sub RunScript
      strAnswer = window.prompt("Please enter the Location to save.", "C:\HTAResults.csv")
 
      If IsNull(strAnswer) Then
            Msgbox "You clicked the Cancel button"
      Else
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            If objFSO.FileExists(strAnswer) = True Then
                  Set objFile = objFSO.OpenTextFile(strAnswer, 8, False)
            Else
                  Set objFile = objFSO.CreateTextFile(strAnswer, True)
                  objFile.Write """Seat No"",""Extension"",""Emp ID"",""Department"",""Designation"",""User Name"",""Login Name"",""Email Address"",""Computer"",""Mobile"",""Company"",""Address"",""City"",""State"",""Zip Code"",""Country"",""Home Phone"""
            End If
      
                  For intRow = LBound(arrRows) To UBound(arrRows)
                        arrData = Split(arrRows(intRow), "|TD|")
                  objFile.Write VbCrLf & """" & arrData(0) & """,""" & arrData(1) & """,""" & arrData(2) & """,""" & arrData(3) & _
                        """,""" & arrData(4) & """,""" & arrData(5) & """,""" & arrData(6) & """,""" & arrData(7) & _
                        """,""" & arrData(8) & """,""" & arrData(9) & """,""" & arrData(10) & """,""" & arrData(11) & _
                        """,""" & arrData(12) & """,""" & arrData(13) & """,""" & arrData(14) & """,""" & arrData(15) & _
                        """,""" & arrData(16) & """"
                  Next
            objFile.Close
            MsgBox "Saved."
      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><tr><td align='right'><img src='G:\Tools\oemlogo.bmp'></td></tr></table>     
 <table width='90%' height = '100%' align='center' border='0'>
            <tr>
                  <td align='center' colspan="2">
                        <h3>User Information</h3><br>
                  </td>
            </tr
            <tr>
                  <td align='center' colspan="2">
                        <table border="0">
                              <tr>
                                    <td>
                                          Seat No:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_seatno" name="txt_seatno" onkeypress="vbs:Detect_Search_Field('txt_seatno')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Extension No:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="25" size="40" id="txt_extensionno" name="txt_extensionno" onkeypress="vbs:Detect_Search_Field('txt_extensionno')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Emp ID:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="6" size="10" id="txt_empid" name="txt_empid" onkeypress="vbs:Detect_Search_Field('txt_empid')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Department:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="50" id="txt_department" name="txt_department" onkeypress="vbs:Detect_Search_Field('txt_department')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Designation:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="50" size="70" id="txt_designation" name="txt_designation" onkeypress="vbs:Detect_Search_Field('txt_designation')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          User Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_name" name="txt_name" onkeypress="vbs:Detect_Search_Field('txt_name')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Login Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_loginname" name="txt_loginname" onkeypress="vbs:Detect_Search_Field('txt_loginname')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Email Address:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="50" size="70" id="txt_email" name="txt_email" onkeypress="vbs:Detect_Search_Field('txt_email')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                         Machine Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="16" size="20" id="txt_notes" name="txt_notes" onkeypress="vbs:Detect_Search_Field('txt_notes')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Mobile Number:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_mobileno" name="txt_mobileno" onkeypress="vbs:Detect_Search_Field('txt_mobileno')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Company:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_company" name="txt_company" onkeypress="vbs:Detect_Search_Field('txt_company')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Address:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_address" name="txt_address" onkeypress="vbs:Detect_Search_Field('txt_address')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          City:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_city" name="txt_city" onkeypress="vbs:Detect_Search_Field('txt_city')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          State:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_state" name="txt_state" onkeypress="vbs:Detect_Search_Field('txt_state')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Zip Code:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_zipcode" name="txt_zipcode" onkeypress="vbs:Detect_Search_Field('txt_zipcode')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Country:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_country" name="txt_country" onkeypress="vbs:Detect_Search_Field('txt_country')">
                                          &nbsp&nbspMust search by 2 letter country code
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Home Phone:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_homephone" name="txt_homephone" onkeypress="vbs:Detect_Search_Field('txt_homephone')">
                                    </td>
                              </tr>
                              <tr>
                                    <td colspan="2" align="center">
                                          <br>Showing record&nbsp
                                          <span id="span_currentrecord">
                                          0
                                          </span>
                                          &nbspof&nbsp
                                          <span id="span_totalrecords">
                                          0
                                          </span>
                                          <br>
                                          <input type='button' value='||< First' name='btnFirstEvent'  onClick='vbs:First_Event'>&nbsp&nbsp&nbsp&nbsp&nbsp
                                          <input type='button' value='<< Previous' name='btnPreviousEvent'  onClick='vbs:Previous_Event'>&nbsp&nbsp&nbsp&nbsp&nbsp
                                          <input type='button' value='Next >>' name='btnNextEvent'  onClick='vbs:Next_Event'>&nbsp&nbsp&nbsp&nbsp&nbsp
                                          <input type='button' value='Last >||' name='btnLastEvent'  onClick='vbs:Last_Event'><br><br><br>
                                          <input type='button' value='Clear Form' name='btnClearForm'  onClick='vbs:Clear_Form'>
                                          <input type="button" value="Submit" name="btn_submit" onClick="vbs:Submit_Form">
                                <input id=runbutton  class="button" type="button" value="Save to" name="run_button"  onClick="Runscript">
                                    </td>
                              </tr>
                        </table>
                  </td>
            </tr>
      </table>
 </body>

Open in new window

0
 
LVL 11

Author Comment

by:bsharath
ID: 21766792
Thanks Rob worked perfect.....
0
 
LVL 11

Author Comment

by:bsharath
ID: 21766795
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 21766809
That looks complicated :-)

I'll have a look tomorrow....I'm off home now....have a good night.

Regards,

Rob.
0
 
LVL 11

Author Comment

by:bsharath
ID: 21766842
Thanks... Good night....
0
 
LVL 11

Author Comment

by:bsharath
ID: 21767617
Rob the extension no that comes when typed any of the other data. Can i just get the 4 number
Output is as this

EXT:-8116 (044-3081-8116)

Need output to be as

8116

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 21774402
Try this for the Extension number fix....

Rob.
<head>
<title>User Information</title>
<HTA:APPLICATION 
     APPLICATIONNAME="User Information"
     BORDER="thin"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
</head>
 
<script language="VBScript">
 
' Global variables
Dim arrRows
 
Sub Window_OnLoad
      intWidth = 800
      intHeight = 900
      Me.ResizeTo intWidth, intHeight
      Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
      btnFirstEvent.Disabled = True
      btnPreviousEvent.Disabled = True
      btnNextEvent.Disabled = True
      btnLastEvent.Disabled = True
      btnFirstEvent.Style.Visibility = "Hidden"
      btnPreviousEvent.Style.Visibility = "Hidden"
      btnNextEvent.Style.Visibility = "Hidden"
      btnLastEvent.Style.Visibility = "Hidden"
End Sub
 
Sub Default_Buttons
      If Window.Event.KeyCode = 13 Then
            btn_submit.Click
      ElseIf Window.Event.KeyCode = 27 Then
            Clear_Form
      End If      
End Sub
 
Sub Clear_Form
      txt_seatno.Value = ""
      txt_seatno.style.backgroundColor="#FFFFFF"
      txt_seatno.Disabled = False
      txt_extensionno.Value = ""
      txt_extensionno.style.backgroundColor="#FFFFFF"
      txt_extensionno.Disabled = False
      txt_empid.Value = ""
      txt_empid.style.backgroundColor="#FFFFFF"
      txt_empid.Disabled = False
      txt_department.Value = ""
      txt_department.style.backgroundColor="#FFFFFF"
      txt_department.Disabled = False
      txt_designation.Value = ""
      txt_designation.style.backgroundColor="#FFFFFF"
      txt_designation.Disabled = False
      txt_name.Value = ""
      txt_name.style.backgroundColor="#FFFFFF"
      txt_name.Disabled = False
      txt_loginname.Value = ""
      txt_loginname.style.backgroundColor="#FFFFFF"
      txt_loginname.Disabled = False
      txt_email.Value = ""
      txt_email.style.backgroundColor="#FFFFFF"
      txt_email.Disabled = False
      txt_notes.Value = ""
      txt_notes.style.backgroundColor="#FFFFFF"
      txt_notes.Disabled = False
      txt_mobileno.Value = ""
      txt_mobileno.style.backgroundColor="#FFFFFF"
      txt_mobileno.Disabled = False
      txt_company.Value = ""
      txt_company.style.backgroundColor="#FFFFFF"
      txt_company.Disabled = False
      txt_address.Value = ""
      txt_address.style.backgroundColor="#FFFFFF"
      txt_address.Disabled = False
      txt_city.Value = ""
      txt_city.style.backgroundColor="#FFFFFF"
      txt_city.Disabled = False
      txt_state.Value = ""
      txt_state.style.backgroundColor="#FFFFFF"
      txt_state.Disabled = False
      txt_zipcode.Value = ""
      txt_zipcode.style.backgroundColor="#FFFFFF"
      txt_zipcode.Disabled = False
      txt_country.Value = ""
      txt_country.style.backgroundColor="#FFFFFF"
      txt_country.Disabled = False
      txt_homephone.Value = ""
      txt_homephone.style.backgroundColor="#FFFFFF"
      txt_homephone.Disabled = False
      btnFirstEvent.Style.Visibility = "Hidden"
      btnPreviousEvent.Style.Visibility = "Hidden"
      btnNextEvent.Style.Visibility = "Hidden"
      btnLastEvent.Style.Visibility = "Hidden"
      span_currentrecord.InnerHTML = "0"
      span_totalrecords.InnerHTML = "0"
End Sub
 
Sub Submit_Form
 
      arrFields = Array(_
      		"txt_seatno", _
            "txt_extensionno", _
            "txt_empid", _
            "txt_department", _
            "txt_designation", _
            "txt_name", _
            "txt_loginname", _
            "txt_email", _
            "txt_notes", _
            "txt_mobileno", _
            "txt_company", _
            "txt_address", _
            "txt_city", _
            "txt_state", _
            "txt_zipcode", _
            "txt_country", _
            "txt_homephone" _
      )
      
      boolValid = False
      For Each strField In arrFields
            If Eval(strField & ".Disabled") = True Then
                  boolValid = True
            End If
            If Eval(strField & ".Disabled") = False Then
                  strCurrentField = strField
            End If
      Next
      
      If boolValid = False Then strCurrentField = "INVALID"
      
      Select Case strCurrentField
            Case "txt_seatno"
                  If txt_seatno.Value = "" Then
                              strSearchField = "(physicalDeliveryOfficeName=*)"
                        Else
                              strSearchField = "(physicalDeliveryOfficeName=*" & txt_seatno.Value & "*)"
                        End If
            Case "txt_extensionno"
                  If txt_extensionno.Value = "" Then
                        strSearchField = "(telephoneNumber=*)"
                  Else
                              strSearchField = "(telephoneNumber=*" & txt_extensionno.Value & "*)"
                        End If
            Case "txt_empid"
                  If txt_empid.Value = "" Then
                        strSearchField = "(description=*)"
                  Else
                              strSearchField = "(description=*" & txt_empid.Value & "*)"
                        End If
            Case "txt_department"
                  If txt_department.Value = "" Then
                        strSearchField = "(department=*)"
                  Else
                              strSearchField = "(department=*" & txt_department.Value & "*)"
                        End If
            Case "txt_designation"
                  If txt_designation.Value = "" Then
                        strSearchField = "(title=*)"
                  Else
                              strSearchField = "(title=*" & txt_designation.Value & "*)"
                        End If
            Case "txt_name"
                  If txt_name.Value = "" Then
                              strSearchField = "(cn=*)"
                        Else
                              strSearchField = "(cn=*" & txt_name.Value & "*)"
                        End If
            Case "txt_loginname"
                  If txt_loginname.Value = "" Then
                        strSearchField = "(samAccountName=*)"
                  Else
                              strSearchField = "(samAccountName=*" & txt_loginname.Value & "*)"
                        End If
            Case "txt_email"
                  If txt_email.Value = "" Then
                        strSearchField = "(mail=*)"
                  Else
                              strSearchField = "(mail=*" & txt_email.Value & "*)"
                        End If
            Case "txt_notes"
                  If txt_notes.Value = "" Then
                        strSearchField = "(info=*)"
                  Else
                              strSearchField = "(info=*" & txt_notes.Value & "*)"
                        End If
            Case "txt_mobileno"
                  If txt_mobileno.Value = "" Then
                        strSearchField = "(mobile=*)"
                  Else
                              strSearchField = "(mobile=*" & txt_mobileno.Value & "*)"
                        End If
            Case "txt_company"
                  If txt_company.Value = "" Then
                        strSearchField = "(company=*)"
                  Else
                              strSearchField = "(company=*" & txt_company.Value & "*)"
                        End If
            Case "txt_address"
                  If txt_address.Value = "" Then
                        strSearchField = "(streetAddress=*)"
                  Else
                              strSearchField = "(streetAddress=*" & txt_address.Value & "*)"
                        End If
            Case "txt_city"
                  If txt_city.Value = "" Then
                        strSearchField = "(l=*)"
                  Else
                              strSearchField = "(l=*" & txt_city.Value & "*)"
                        End If
            Case "txt_state"
                  If txt_state.Value = "" Then
                        strSearchField = "(st=*)"
                  Else
                              strSearchField = "(st=*" & txt_state.Value & "*)"
                        End If
            Case "txt_zipcode"
                  If txt_zipcode.Value = "" Then
                        strSearchField = "(postalCode=*)"
                  Else
                              strSearchField = "(postalCode=*" & txt_zipcode.Value & "*)"
                        End If
            Case "txt_country"
                  If txt_country.Value = "" Then
                        strSearchField = "(c=*)"
                  Else
                              strSearchField = "(c=*" & txt_country.Value & "*)"
                        End If
            Case "txt_homephone"
                  If txt_homephone.Value = "" Then
                        strSearchField = "(homePhone=*)"
                  Else
                              strSearchField = "(homePhone=*" & txt_homephone.Value & "*)"
                        End If
            Case Else
                  strSearchField = "INVALID"
      End Select
 
      Clear_Form
      
      If strSearchField <> "INVALID" Then
            Set adoCommand = CreateObject("ADODB.Command")
            Set adoConnection = CreateObject("ADODB.Connection")
            adoConnection.Provider = "ADsDSOObject"
            adoConnection.Open "Active Directory Provider"
            adoCommand.ActiveConnection = adoConnection
            
             ' Search entire Active Directory domain.
            Set objRootDSE = GetObject("LDAP://RootDSE")
            
            strDNSDomain = objRootDSE.Get("defaultNamingContext")
            strBase = "<LDAP://" & strDNSDomain & ">"
            
            strFilter = "(&(objectCategory=person)(objectClass=user)" & strSearchField & ")"
            'strFilter = "(&(objectClass=computer)(cn=" & strComputer & "))"
            
            ' Comma delimited list of attribute values to retrieve.
            strAttributes = "physicalDeliveryOfficeName,TelephoneNumber,description,Department,Title,cn,samAccountName,mail,Info,Mobile,company,streetAddress,l,st,postalCode,c,homePhone"
            
            ' Construct the LDAP syntax query.
            strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
            adoCommand.CommandText = strQuery
            adoCommand.Properties("Page Size") = 100
            adoCommand.Properties("Timeout") = 30
            adoCommand.Properties("Cache Results") = False
 
            ' Run the query.
            Set adoRecordset = adoCommand.Execute
             
            ' Enumerate the resulting recordset.
            strDetails = ""
            If Not adoRecordset.EOF Then
                  Do Until adoRecordset.EOF
                        If strDetails = "" Then
                              strDetails = adoRecordset.Fields("physicalDeliveryOfficeName").Value
                              					strTelephoneNumber = adoRecordset.Fields("TelephoneNumber").Value
                              					intStart = 0
                              					intEnd = 0
                              					If Len(strTelephoneNumber) > 0 Then
	                              					For intChr = 1 To Len(strTelephoneNumber)
	                              						If intStart > 0 And IsNumeric(Mid(strTelephoneNumber, intChr, 1)) = False Then
	                              							intEnd = intChr - 1
	                              						ElseIf intStart = 0 And IsNumeric(Mid(strTelephoneNumber, intChr, 1)) = True Then
	                              							intStart = intChr
	                              						End If
	                              						If intStart > 0 And intEnd > 0 Then Exit For
	                              					Next
	                              					strTelephoneNumber = Left(Mid(strTelephoneNumber, intStart), intEnd - (intStart - 1))
	                              				End If
                                                strDetails = strDetails & "|TD|" & strTelephoneNumber
                                                If IsNull(adoRecordset.Fields("Description").Value) = False Then
                                                      strDetails = strDetails & "|TD|" & Join(adoRecordset.Fields("description").Value)
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Department").Value &_
                                                "|TD|" & adoRecordset.Fields("Title").Value &_
                              					"|TD|" & Replace(adoRecordset.Fields("cn").Value, "CN=", "") &_
                                                "|TD|" & adoRecordset.Fields("samAccountName").Value &_
                                                "|TD|" & adoRecordset.Fields("mail").Value
                                                If IsNull(adoRecordset.Fields("Info").Value) = False Then
                                                      If Left(LCase(adoRecordset.Fields("Info").Value), 15) = LCase("Machine Name : ") Then
                                                      	strInfo = Trim(Mid(adoRecordset.Fields("Info").Value, 15))
                                                      Else
                                                      	strInfo = adoRecordset.Fields("Info").Value
                                                      End If
                                                      strDetails = strDetails & "|TD|" & strInfo
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Mobile").Value &_
                                                "|TD|" & adoRecordset.Fields("company").Value &_
                                                "|TD|" & adoRecordset.Fields("streetAddress").Value &_
                                                "|TD|" & adoRecordset.Fields("l").Value &_
                                                "|TD|" & adoRecordset.Fields("st").Value &_
                                                "|TD|" & adoRecordset.Fields("postalCode").Value &_
                                                "|TD|" & adoRecordset.Fields("c").Value &_
                                                "|TD|" & adoRecordset.Fields("homePhone").Value
                        Else
                              strDetails = adoRecordset.Fields("physicalDeliveryOfficeName").Value
                              					strTelephoneNumber = adoRecordset.Fields("TelephoneNumber").Value
                              					intStart = 0
                              					intEnd = 0
                              					If Len(strTelephoneNumber) > 0 Then
	                              					For intChr = 1 To Len(strTelephoneNumber)
	                              						If intStart > 0 And IsNumeric(Mid(strTelephoneNumber, intChr, 1)) = False Then
	                              							intEnd = intChr - 1
	                              						ElseIf intStart = 0 And IsNumeric(Mid(strTelephoneNumber, intChr, 1)) = True Then
	                              							intStart = intChr
	                              						End If
	                              						If intStart > 0 And intEnd > 0 Then Exit For
	                              					Next
	                              					strTelephoneNumber = Left(Mid(strTelephoneNumber, intStart), intEnd - (intStart - 1))
	                              				End If
                                                strDetails = strDetails & "|TD|" & strTelephoneNumber
                                                If IsNull(adoRecordset.Fields("Description").Value) = False Then
                                                      strDetails = strDetails & "|TD|" & Join(adoRecordset.Fields("description").Value)
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Title").Value &_
                                                "|TD|" & adoRecordset.Fields("Department").Value &_
                              					"|TD|" & Replace(adoRecordset.Fields("cn").Value, "CN=", "") &_
                                                "|TD|" & adoRecordset.Fields("samAccountName").Value &_
                                                "|TD|" & adoRecordset.Fields("mail").Value
                                                If IsNull(adoRecordset.Fields("Info").Value) = False Then
                                                      If Left(LCase(adoRecordset.Fields("Info").Value), 15) = LCase("Machine Name : ") Then
                                                      	strInfo = Trim(Mid(adoRecordset.Fields("Info").Value, 15))
                                                      Else
                                                      	strInfo = adoRecordset.Fields("Info").Value
                                                      End If
                                                      strDetails = strDetails & "|TD|" & strInfo
                                                Else
                                                      strDetails = strDetails & "|TD|"
                                                End If
                                                strDetails = strDetails & "|TD|" & adoRecordset.Fields("Mobile").Value &_
                                                "|TD|" & adoRecordset.Fields("company").Value &_
                                                "|TD|" & adoRecordset.Fields("streetAddress").Value &_
                                                "|TD|" & adoRecordset.Fields("l").Value &_
                                                "|TD|" & adoRecordset.Fields("st").Value &_
                                                "|TD|" & adoRecordset.Fields("postalCode").Value &_
                                                "|TD|" & adoRecordset.Fields("c").Value &_
                                                "|TD|" & adoRecordset.Fields("homePhone").Value
                        End If
                      adoRecordset.MoveNext
                  Loop
            Else
                  MsgBox "No records were found"
            End If
            
            ' Clean up.
            adoRecordset.Close
            Set adoRecordset = Nothing
            
            adoConnection.Close
      
            If strDetails <> "" Then
                  arrRows = ""
                  arrRows = Split(strDetails, "|TR|")
                  If UBound(arrRows) < 0 Then
                        span_currentrecord.InnerHTML = "0"
                        span_totalrecords.InnerHTML = "0"
                  Else
                        arrData = Split(arrRows(0), "|TD|")
						txt_seatno.Value = arrData(0)
                        txt_extensionno.Value = arrData(1)
                        txt_empid.Value = arrData(2)
                        txt_department.Value = arrData(3)
                        txt_designation.Value = arrData(4)
                        txt_name.Value = arrData(5)
                        txt_loginname.Value = arrData(6)
                        txt_email.Value = arrData(7)
                        txt_notes.Value = arrData(8)
                        txt_mobileno.Value = arrData(9)
                        txt_company.Value = arrData(10)
                        txt_address.Value = arrData(11)
                        txt_city.Value = arrData(12)
                        txt_state.Value = arrData(13)
                        txt_zipcode.Value = arrData(14)
                        txt_country.Value = arrData(15)
                        txt_homephone.Value = arrData(16)
                        span_currentrecord.InnerHTML = "1"
                        span_totalrecords.InnerHTML = UBound(arrRows) + 1
                  End If
            Else
                  span_currentrecord.InnerHTML = "0"
                  span_totalrecords.InnerHTML = "0"
            End If
            If strDetails = "" Then
                  btnFirstEvent.Disabled = True
                  btnPreviousEvent.Disabled = True
                  btnNextEvent.Disabled = True
                  btnLastEvent.Disabled = True      
                  btnFirstEvent.Style.Visibility = "Hidden"
                  btnPreviousEvent.Style.Visibility = "Hidden"
                  btnNextEvent.Style.Visibility = "Hidden"
                  btnLastEvent.Style.Visibility = "Hidden"
            ElseIf UBound(arrRows) = 0 Then
                  btnFirstEvent.Disabled = True
                  btnPreviousEvent.Disabled = True
                  btnNextEvent.Disabled = True
                  btnLastEvent.Disabled = True
                  btnFirstEvent.Style.Visibility = "Hidden"
                  btnPreviousEvent.Style.Visibility = "Hidden"
                  btnNextEvent.Style.Visibility = "Hidden"
                  btnLastEvent.Style.Visibility = "Hidden"
            Else
                  btnFirstEvent.Disabled = False
                  btnPreviousEvent.Disabled = False
                  btnNextEvent.Disabled = False
                  btnLastEvent.Disabled = False
                  btnFirstEvent.Style.Visibility = "Visible"
                  btnPreviousEvent.Style.Visibility = "Visible"
                  btnNextEvent.Style.Visibility = "Visible"
                  btnLastEvent.Style.Visibility = "Visible"
            End If
      Else
            MsgBox "Please type a search request into one of the fields, then click Submit."
      End If
      
End Sub
 
Sub Get_Event
 
	arrData = Split(arrRows(span_currentrecord.InnerHTML - 1), "|TD|")
	txt_seatno.Value = arrData(0)
	txt_extensionno.Value = arrData(1)
	txt_empid.Value = arrData(2)
	txt_department.Value = arrData(3)
	txt_designation.Value = arrData(4)
	txt_name.Value = arrData(5)
	txt_loginname.Value = arrData(6)
	txt_email.Value = arrData(7)
	txt_notes.Value = arrData(8)
	txt_mobileno.Value = arrData(9)
	txt_company.Value = arrData(10)
	txt_address.Value = arrData(11)
	txt_city.Value = arrData(12)
	txt_state.Value = arrData(13)
	txt_zipcode.Value = arrData(14)
	txt_country.Value = arrData(15)
	txt_homephone.Value = arrData(16)
 
End Sub
 
Sub First_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_totalrecords.InnerHTML < 1 Then
                  MsgBox "There are no records to display"
            ElseIf span_currentrecord.InnerHTML = 1 Then
                  MsgBox "You are already viewing the first record."
            Else
                  span_currentrecord.InnerHTML = 1
                  Get_Event
            End If
      End If
      
End Sub
 
Sub Previous_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_currentrecord.InnerHTML > 1 Then
                  span_currentrecord.InnerHTML = span_currentrecord.InnerHTML - 1
                  Get_Event
            ElseIf span_currentrecord.InnerHTML = 1 Then
                        MsgBox "You are already viewing the first record."
            Else
                  MsgBox "There are no records to display"
            End If
      End If
 
End Sub
 
Sub Next_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_totalrecords.InnerHTML = 0 Then
                  MsgBox "There are no records for to display"
            ElseIf span_currentrecord.InnerHTML = span_totalrecords.InnerHTML Then
                  MsgBox "You are already viewing the last record."
            Else
                  span_currentrecord.InnerHTML = span_currentrecord.InnerHTML + 1
                  Get_Event
            End If
      End If
      
End Sub
 
Sub Last_Event
      
      If IsArray(arrRows) = False Then
            MsgBox "There are no records to display."
      Else
            If span_totalrecords.InnerHTML = 0 Then
                  MsgBox "There are no records to display"
            ElseIf span_currentrecord.InnerHTML = span_totalrecords.InnerHTML Then
                        MsgBox "You are already viewing the last record."
            Else
                  span_currentrecord.InnerHTML = span_totalrecords.InnerHTML
                  Get_Event
            End If
      End If
      
End Sub
 
Sub Detect_Search_Field(strCurrentField)
      arrFields = Array(_
      		"txt_seatno", _
            "txt_extensionno", _
            "txt_empid", _
            "txt_department", _
            "txt_designation", _
            "txt_name", _
            "txt_loginname", _
            "txt_email", _
            "txt_notes", _
            "txt_mobileno", _
            "txt_company", _
            "txt_address", _
            "txt_city", _
            "txt_state", _
            "txt_zipcode", _
            "txt_country", _
            "txt_homephone" _
      )
      
      For Each strField In arrFields
            If LCase(strField) <> LCase(strCurrentField) Then
                  Execute strField & ".style.backgroundColor=""#D3D3D3"""
                  Execute strField & ".Disabled = True"
            End If
      Next
End Sub
 
Sub RunScript
      strAnswer = window.prompt("Please enter the Location to save.", "C:\HTAResults.csv")
 
      If IsNull(strAnswer) Then
            Msgbox "You clicked the Cancel button"
      Else
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            If objFSO.FileExists(strAnswer) = True Then
                  Set objFile = objFSO.OpenTextFile(strAnswer, 8, False)
            Else
                  Set objFile = objFSO.CreateTextFile(strAnswer, True)
                  objFile.Write """Seat No"",""Extension"",""Emp ID"",""Department"",""Designation"",""User Name"",""Login Name"",""Email Address"",""Computer"",""Mobile"",""Company"",""Address"",""City"",""State"",""Zip Code"",""Country"",""Home Phone"""
            End If
      
                  For intRow = LBound(arrRows) To UBound(arrRows)
                        arrData = Split(arrRows(intRow), "|TD|")
                  objFile.Write VbCrLf & """" & arrData(0) & """,""" & arrData(1) & """,""" & arrData(2) & """,""" & arrData(3) & _
                        """,""" & arrData(4) & """,""" & arrData(5) & """,""" & arrData(6) & """,""" & arrData(7) & _
                        """,""" & arrData(8) & """,""" & arrData(9) & """,""" & arrData(10) & """,""" & arrData(11) & _
                        """,""" & arrData(12) & """,""" & arrData(13) & """,""" & arrData(14) & """,""" & arrData(15) & _
                        """,""" & arrData(16) & """"
                  Next
            objFile.Close
            MsgBox "Saved."
      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><tr><td align='right'><img src='G:\Tools\oemlogo.bmp'></td></tr></table>     
 <table width='90%' height = '100%' align='center' border='0'>
            <tr>
                  <td align='center' colspan="2">
                        <h3>User Information</h3><br>
                  </td>
            </tr
            <tr>
                  <td align='center' colspan="2">
                        <table border="0">
                              <tr>
                                    <td>
                                          Seat No:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_seatno" name="txt_seatno" onkeypress="vbs:Detect_Search_Field('txt_seatno')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Extension No:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="25" size="40" id="txt_extensionno" name="txt_extensionno" onkeypress="vbs:Detect_Search_Field('txt_extensionno')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Emp ID:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="6" size="10" id="txt_empid" name="txt_empid" onkeypress="vbs:Detect_Search_Field('txt_empid')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Department:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="50" id="txt_department" name="txt_department" onkeypress="vbs:Detect_Search_Field('txt_department')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Designation:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="50" size="70" id="txt_designation" name="txt_designation" onkeypress="vbs:Detect_Search_Field('txt_designation')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          User Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_name" name="txt_name" onkeypress="vbs:Detect_Search_Field('txt_name')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Login Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="30" size="40" id="txt_loginname" name="txt_loginname" onkeypress="vbs:Detect_Search_Field('txt_loginname')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Email Address:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="50" size="70" id="txt_email" name="txt_email" onkeypress="vbs:Detect_Search_Field('txt_email')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                         Machine Name:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="16" size="20" id="txt_notes" name="txt_notes" onkeypress="vbs:Detect_Search_Field('txt_notes')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Mobile Number:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_mobileno" name="txt_mobileno" onkeypress="vbs:Detect_Search_Field('txt_mobileno')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Company:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_company" name="txt_company" onkeypress="vbs:Detect_Search_Field('txt_company')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Address:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_address" name="txt_address" onkeypress="vbs:Detect_Search_Field('txt_address')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          City:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_city" name="txt_city" onkeypress="vbs:Detect_Search_Field('txt_city')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          State:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_state" name="txt_state" onkeypress="vbs:Detect_Search_Field('txt_state')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Zip Code:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_zipcode" name="txt_zipcode" onkeypress="vbs:Detect_Search_Field('txt_zipcode')">
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Country:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_country" name="txt_country" onkeypress="vbs:Detect_Search_Field('txt_country')">
                                          &nbsp&nbspMust search by 2 letter country code
                                    </td>
                              </tr>
                              <tr>
                                    <td>
                                          Home Phone:
                                    </td>
                                    <td>
                                          <input type="text" maxlength="14" size="20" id="txt_homephone" name="txt_homephone" onkeypress="vbs:Detect_Search_Field('txt_homephone')">
                                    </td>
                              </tr>
                              <tr>
                                    <td colspan="2" align="center">
                                          <br>Showing record&nbsp
                                          <span id="span_currentrecord">
                                          0
                                          </span>
                                          &nbspof&nbsp
                                          <span id="span_totalrecords">
                                          0
                                          </span>
                                          <br>
                                          <input type='button' value='||< First' name='btnFirstEvent'  onClick='vbs:First_Event'>&nbsp&nbsp&nbsp&nbsp&nbsp
                                          <input type='button' value='<< Previous' name='btnPreviousEvent'  onClick='vbs:Previous_Event'>&nbsp&nbsp&nbsp&nbsp&nbsp
                                          <input type='button' value='Next >>' name='btnNextEvent'  onClick='vbs:Next_Event'>&nbsp&nbsp&nbsp&nbsp&nbsp
                                          <input type='button' value='Last >||' name='btnLastEvent'  onClick='vbs:Last_Event'><br><br><br>
                                          <input type='button' value='Clear Form' name='btnClearForm'  onClick='vbs:Clear_Form'>
                                          <input type="button" value="Submit" name="btn_submit" onClick="vbs:Submit_Form">
                                <input id=runbutton  class="button" type="button" value="Save to" name="run_button"  onClick="Runscript">
                                    </td>
                              </tr>
                        </table>
                  </td>
            </tr>
      </table>
 </body>

Open in new window

0
 
LVL 11

Author Comment

by:bsharath
ID: 21775425
Thanks Rob works perfect...
Which is the row i need to change for background color
0
 
LVL 11

Author Comment

by:bsharath
ID: 21775426
Thanks Rob works perfect...
Which is the row i need to change for background color
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 21775527
For the background colour of the whole HTA, change this:
<body STYLE="font:14 pt arial; color:white;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>

where there's a HEX value for StartColorStr and EndColorStr.  Color codes can be found here:
http://msdn.microsoft.com/en-us/library/ms537433(VS.85).aspx

If you only want a single colour, change that to
<body STYLE="font:14 pt arial; color:white;background-color='#0000FF'" onkeypress='vbs:Default_Buttons'>

Regards,

Rob.
0
 
LVL 11

Author Comment

by:bsharath
ID: 21775538
Thanks Rob...
0
 
LVL 11

Author Comment

by:bsharath
ID: 21775868
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question