Solved

.hta file needs a "Please wait..." message

Posted on 2010-09-04
2
975 Views
Last Modified: 2012-06-21
Hello mates,

I am just dabbling into .hta application development.

The code below works great, just like we want it.

The only missing bit is when a user tries searching the db for records, I need to give the user a message that says, "Search in progress, please wait..."

I have done this tons of times with other languages but having feats giving it a go with .hta.

Any assistance with this bit is highly appreciated.

This is entire working code. Thanks much in advance.

<html>
<HTA:APPLICATION ID="oHTA"
     APPLICATIONNAME="default"
	 BORDER="thin"
	 BORDERSTYLE="normal"
	 CAPTION="yes"
	 ICON=PBTC.ico
	 MAXIMIZEBUTTON="yes"
	 MINIMIZEBUTTON="yes"
	 SHOWINTASKBAR="no"
	 SINGLEINSTANCE="no"
	 SYSMENU="yes"
	 VERSION=7.2
	 WINDOWSTATE="maximize"
	 contextMenu=no
  >
<head>

<script type="text/javascript">

var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="Yes" //Collapse previously open content when opening present? (yes/no)

if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(cid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
getElementbyClass("switchcontent")
if (enablepersist=="on" && typeof ccollect!="undefined"){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
}


if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate

</script>

<title>PCourt Montly Report</title>

<script language="vbscript">

Dim conn 'GLOBAL doing this here so that all functions can use it

sub dotheconnection

set conn=CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB;Data Source=10.48.5.120,1433;Network Library=DBMSSOCN;" &_
"Initial Catalog=PCCourt;User ID=prtUsers;Password=prbusers;"

	If conn.errors.count <> 0 Then 
	
		alert("problem connecting to the database")
	else
		' if connected OK call sub getdata
	end if
end sub

sub searchdata

	SQL_query = "SELECT Name, Rel, Estno, dtfild, pub, typeofdocument, btyp, bkno, pgno, disp, dispdt FROM PCS60418_MTHLY_XREF WHERE NAME LIKE '%" & Replace(txtsrch.value, "'", "''") & "%' ORDER BY NAME "
	Set rsData = conn.Execute(SQL_query)
        If rsData.EOF Then
	msgbox  "No records found. Please refine your search"

       else 
       
        strHTML = strHTML & "<table cellspacing='0' cellpadding='4' border='0' width='100%'>"
	strHTML = strHTML & "<tr style='background-color:#69C; color:#FFFFFF; font-size: x-small;font-weight:bold'>"
	strHTML = strHTML & "<th>NAME</th>"
	strHTML = strHTML & "<th>REL</th>"
	strHTML = strHTML & "<th>ESTATE NO</th>"
	strHTML = strHTML & "<th>DATE FILLED</th>"
	strHTML = strHTML & "<th>PUB</th>"
	strHTML = strHTML & "<th>TYPE OF DOCUMENT</th>"
	strHTML = strHTML & "<th>BOOK TYPE</th>"
	strHTML = strHTML & "<th>BOOK NO</th>"
	strHTML = strHTML & "<th>PAGE NO</th>"
	strHTML = strHTML & "<th>DISPOSITION</th>"
	strHTML = strHTML & "<th>DISP DATE</th>"
        strHTML = strHTML & "</tr>"
      
          Dim colorset, numcolors
      	 '/--- This is the array of colors to use. -------------\
      	  colorset = split("gainsboro,White",",")
      	  numcolors = ubound(colorset)+1

       priorRec=""
     Do Until rsData.EOF
       curRec= rsData("Name") 
       curRel = rsData("Rel")
       If curRec <> priorRec Then
           
            strHTML = strHTML & "<tr>" 
            strHTML = strHTML & "<td style='background:gainsboro;font-size: x-small;'>" & rsData("Name") & "</td>"
            strHTML = strHTML & "<td style='background:gainsboro;font-size: x-small;font-size: x-small;'>" & rsData("REL") & "</td>"      
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;'>" & rsData("ESTNO") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;'>" & rsData("DTFILD") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;'>" & rsData("PUB") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;'>" & rsData("TypeOfDocument") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;'>" & rsData("BTYP") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;'>" & rsData("BKNO") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;'>" & rsData("PGNO") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;'>" & rsData("DISP") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;'>" & rsData("DISPDT") & "</td>"
            strHTML = strHTML & "</tr><tr>"
            
            priorRec = curRec
            priorRel = curRel

       Else
       
            strHTML = strHTML & "<tr>" 
            strHTML = strHTML & "<td style='background:White;font-size: x-small;'> &nbsp; </td>"
            strHTML = strHTML & "<td style='background:White;font-size: x-small;'>&nbsp;</td>"      
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;' >" & rsData("ESTNO") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;' >" & rsData("DTFILD") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;' >" & rsData("PUB") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;' >" & rsData("TypeOfDocument") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;' >" & rsData("BTYP") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;' >" & rsData("BKNO") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;' >" & rsData("PGNO") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;' >" & rsData("DISP") & "</td>"
            strHTML = strHTML & "<td style='background:" & colorset(i mod numcolors) & ";font-size: x-small;' >" & rsData("DISPDT") & "</td>"
            strHTML = strHTML & "</tr>"    
      end if
 
            i = i + 1
            rsData.MoveNext
      Loop

        strHTML = strHTML & "</table>"
        searchIT.innerHTML = strHTML
    end if
end sub

</script>
<style>
<!--
fieldset     { border: 1 solid #000080 }
font         { font-family: Verdana; font-size: 10pt }
-->
</style>
<LINK href="/probateCT/include/template.css" rel="stylesheet" type="text/css">
</head>
<body onload="dotheconnection" language="vbscript" background="images/fond.gif">

<font face="Verdana" size="2">

<div align=center><input type="button" style="width: 580px;" value="Search Probate Court Monthly Report Database Click here>>>" onClick="expandcontent('sc2')" style="font-size: medium; font-weight: bold; color:#ffffff; background-color:#69C;"></div>

<div id="sc2" class="switchcontent">

<div align="center">
 <table border="0" width="470" height="16">
    <tr>
      <td height="6" class="bgtop" nowrap>
     <b><font style="font-size: medium; font-weight: bold; color:#ffffff;">Enter Name:</font></b></td>
     <td width="487" height="7"><b><font face="Verdana" size="2"><input type="text" name="txtsrch" size="43"></font></b><input type="button" name="btnSearch" class="bgtop" value="Go" onclick="searchdata" language="vbscript" style="font-size: medium; font-weight: bold; color:#ffffff; background-color:#6e6e6e;">
      </td>
      </tr><tr><td width="126"></td><td width="487"><b><font color="#000080" size="2" face="Verdana">
        You can search by a keyword e.g.; Gibbs<br>
        You can also search in the format of Lastname, Firstname Middle name.<br>
        Example: Adams, Eva Gibbs</font></b>
      </td>
    </tr>
     </table>
</div>

<fieldset>
<legend><b><font style="font-size: medium; font-weight: bold; color:#6e6e6e; background-color:gainsboro;">Search Results</font></b></legend>
<center><div style="width: 950; height: 500; overflow: auto; border: 0px solid black" id="searchIT"></div>
</center>
</fieldset>
</body>
</script>

Open in new window

0
Comment
Question by:sammySeltzer
2 Comments
 
LVL 8

Accepted Solution

by:
spinzr0 earned 250 total points
ID: 33605079
I generally find it easiest to just pop up an IE window with the message when working in HTAs because they won't update until the command finishes.  Here is some code to do it.
Set oIE = CreateObject("InternetExplorer.Application")
Call CreatePopup()
Wscript.Sleep 5000
oIE.Quit
Set oIE = Nothing

'**************************************************************************
'Creates the progress bar so the user sees that the process is running
'**************************************************************************
Sub CreatePopup()
    On Error Resume Next

    sPBTitle = "Please Wait"
    iWindowWidth = 300
    iWindowHeight = 100
    With oIE
        .Navigate "about:blank"
        .ToolBar = False
        .StatusBar = False
        .MenuBar = False
        .Resizable = False
        .Width = iWindowWidth
        .Height = iWindowHeight 
        .Left = (.Document.ParentWindow.Screen.AvailWidth - iWindowWidth) / 2
        .Top = (.Document.ParentWindow.Screen.AvailHeight - iWindowHeight) / 2
        With .Document
            .Open
            .Write "<html><head><title>" & sPBTitle & "</title></head>" &_ 
                   "<body bgcolor=""buttonface"">" &_ 
                   "Search in progress, please wait..." &_ 
                   "</body></html>"
            .Close
            .Title = sPBTitle
        End With
        .Visible = True             
    End With
    Do While oIE.Busy : WScript.Sleep 100 : Loop
End Sub

Open in new window

0
 
LVL 28

Author Comment

by:sammySeltzer
ID: 33633283
I was able to find a nifty way of doing this and it does work for me now.

I wan to thank you for all your efforts.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

777 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