|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Cannot get window.setInterval logic (VBS)
hey all...i have no idea why i can't get the logic down with this...
i have an hta...in which cannot use sleep so ended up choosing window.setInterval the problem: i have successfully displayed the loader however...my logic was off...i was displaying the loader delay>loop>display loop results i would have said screw it...however...with large returns...this is not feasible...so... how do i simply show a loader(animated.gif) WHILE the loop is collecting data? ...it's rather embarrassing to say...but i simply cannot get it to work thanks Code:
<html>
<head>
<title>Student Account</title>
<style>
div.results {width:100%;height:300px;overflow-y:scroll;}
table {border:1px solid black;width:75%;}
th {width:33%;background:#eee;padding-left:75px;}
table.results {border:none;width:100%;}
td {text-align:center;}
img.loader {position:relative;left:50px;top:25px;}
</style>
<hta:application
windowState="normal">
<script language="VBScript">
Dim oConn, iTimerID
Sub DisplayStudentAccts(sUserInput)
If Len(sUserInput) > 0 Then
Set oRootDSE = GetObject("LDAP://RootDSE")
sConfig = oRootDSE.Get("configurationNamingContext")
sDomainAdsPAth = oRootDSE.Get("defaultNamingContext")
sAdsPath = "OU=Student Users," & sDomainAdsPAth
Set oConn = CreateObject("ADODB.Connection")
oConn.Provider = "ADsDSOObject"
oConn.Open "Active Directory Provider"
on error resume next
Set oRs = oConn.Execute("SELECT cn, adspath " & _
"FROM 'LDAP://" & sAdsPath & "'" & _
"WHERE cn='" & sUserInput & "*'")
If Not oRs.EOF Then
sRowColor = "white"
iTimerID = window.setInterval("DisplayLoader", 500,"vbscript")
Do While Not oRs.EOF
iCount = iCount + 1
iStuAcctTot = oRs.Recordcount
sAdsPath = oRs("ADsPath")
Set oStudentAcct = GetObject(sAdsPath)
dPwdLastChanged = oStudentAcct.PasswordLastChanged
If iCount < iStuAcctTot Then
DisplayLoader
If Len(dPwdLastChanged) = 0 Then dPwdLastChanged = "Password never set"
sResults = sResults & "<tr bgcolor=""" & sRowColor & """>" & _
" <td>" & iCount & "</td>" & _
" <td>" & oRs("cn") & "</td>" & _
" <td>" & dPwdLastChanged & "</td>" & _
" <td><input type=""checkbox"" name=""stuacctck"" value=""" & oRs("cn") & """>" & _
"</tr>"
If sRowColor = "white" Then
sRowColor = "#eeeeee"
Else
sRowColor = "white"
End If
Else
window.clearInterval(iTimerID)
End If
oRs.MoveNext
Loop
results.innerhtml = "<table cellspacing=""1"">" & _
" <tr>" & _
" <th>#</th>" & _
" <th>Student Account</th>" & _
" <th>Password Last Changed</th>" & _
" <th><a href=""#"" onclick=""checkAll(stuacctck)"">Select All</th>" & _
" </tr>" & _
" <tr>" & _
" <td colspan=""4"">" & _
" <div class=""results"">" & _
" <table class=""results"">" & _
sResults & _
" </table>" & _
" </div>" & _
" </td>" & _
" </tr>" & _
"</table>"
Else
results.innerhtml = "<img src=""http://webs.wichita.edu/depttools/depttoolsmemberfiles/accomp/question_mark%20(WinCE).jpg"">"
End If
End If
End Sub
Sub DisplayLoader
results.innerHtml = "<img class=""loader"" src=""http://www.dzone.com/images/std/ajax-loader-85.gif"">"
End Sub
</script>
</head>
<body>
Student Account: <input id="stuacct">
<input type="button" value="Go" onclick="DisplayStudentAccts(stuacct.value)">
<div id="results"></div>
</body>
</html>
|
|
#2
|
||||
|
||||
|
guess i may have posted in the wrong forum hence no replies...but if interested here is the bare boned version i came up w/ ...it may come in handy for an ad/database admin
<edit>forgot to mention...this code satifies my request....although it's a stripped down version of what i have...it does accurately display an animated gif while the process is running in the background</edit> Code:
<html>
<head>
<hta:application />
<script language="VBScript">
Option Explicit
Dim oConn, oRs
Dim oRootDSE, sRootAdsPath
Dim i, iTimerID, iStuAcctTot, aStuAccts, sResults, sUserInput
Function CollectStudentAccts
sUserInput = stuacct.value
If Len(sUserInput) > 0 Then
OpenActDir
Set oRs = oConn.Execute("SELECT cn " & _
"FROM 'LDAP://" & GetAdsPath & "'" & _
"WHERE cn='" & sUserInput & "*'")
If Not oRs.EOF Then
CollectStudentAccts = oRs.GetRows
End If
End If
End Function
Sub DisplayStuAccts
If i <= iStuAcctTot Then
If i = i mod 2 Then DisplayLoader
sResults = sResults & "<tr>" & _
" <td>" & aStuAccts(0,i) & "</td>" & _
"</tr>"
i = i + 1
Else
window.clearInterval(iTimerID)
results.innerhtml = "<table border=""1"">" & sResults & "</table>"
sResults = ""
End If
End Sub
Sub DisplayLoader
results.innerHtml = "<img class=""loader"" src=""http://www.dzone.com/images/std/ajax-loader-85.gif"">"
End Sub
Sub Main
If Len(stuacct.value) > 0 Then
aStuAccts = CollectStudentAccts
If isArray(aStuAccts) Then
iStuAcctTot = UBound(aStuAccts,2)
i = 0
iTimerID = window.setInterval("DisplayStuAccts",1,"vbscript")
Else
results.innerhtml = "No Recs"
End If
Else
results.innerhtml = "Data Entry Required"
End If
End Sub
Function GetAdsPath
Set oRootDSE = GetObject("LDAP://RootDSE")
sRootAdsPath = oRootDSE.Get("defaultNamingContext")
GetAdsPath = "CN=Users," & sRootAdsPath
End Function
Function OpenActDir
Set oConn = CreateObject("ADODB.Connection")
oConn.Provider = "ADsDSOObject"
oConn.Open "Active Directory Provider"
End Function
</script>
</head>
<body>
Student Account: <input id="stuacct">
<input type="button" value="Go" onclick="Main">
<div id="results"></div>
</body>
</html>
Last edited by keep_it_simple : October 20th, 2007 at 11:23 PM. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Cannot get window.setInterval logic (VBS) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|