working with HTA

Hi team,

Ordinarily, this code would be a breeze in any other language but for some reason, mostly due to no coffee intake today, I can't get it to display the data.

No errors; just not rendering the data to the screen.

Any ideas, please?

<html>
<HTA:APPLICATION ID="oHTA"
     APPLICATIONNAME="myApp"
	 BORDER="thin"
	 BORDERSTYLE="normal"
	 CAPTION="yes"
	 ICON=./Art/callwrap.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>Probate Court 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=25.68.5.120,1433;Network Library=DBMSSOCN;" &_
"Initial Catalog=PBCt;User ID=probctUsers;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 * FROM PCS60418_MTHLY_XREF WHERE NAME LIKE '%" & Replace(txtsrch.value, "'", "''") & "%' ORDER BY NAME "
	Set rsData = conn.Execute(SQL_query)
        
        strHTML2 = strHTML2 & "<table cellspacing='0' cellpadding='4' border='1' width='100%'><tr><td bgcolor='#000000'><font color='#FFFFFF'><b>Name</b></font></td><td bgcolor='#000000'><font color='#FFFFFF'><b>Rel</b></font></td><td bgcolor='#000000'><font color='#FFFFFF'><b>EST #</b></font></td><td bgcolor='#000000'><font color='#FFFFFF'><b>DTFILD</b></font></td><td bgcolor='#000000'><font color='#FFFFFF'><b>PUB</b></font></td><td bgcolor='#000000'><font color='#FFFFFF'><b>Type of Document</b></font></td><td bgcolor='#000000'><font color='#FFFFFF'><b>BYTP</b></font></td><td bgcolor='#000000'><font color='#FFFFFF'><b>BKNO</b></font></td><td bgcolor='#000000'><font color='#FFFFFF'><b>PGNO</b></font></td><td bgcolor='#000000'><font color='#FFFFFF'><b>DISP</b></font></td><td bgcolor='#000000'><font color='#FFFFFF'><b>DISPDT</b></font></td></tr>"
	Do Until rsData.EOF
		txtNAME.value           = rsData("NAME")
		txtREL.value            = rsData("REL")
		txtESTNO.value          = rsData("ESTNO")
		txtDTFILD.value         = rsData("DTFILD")
		txtPUB.value            = rsData("PUB")
		txtTypeOfDocument.value = rsData("TYPEOFDOCUMENT")
		txtBTYP.value           = rsData("BTYP")
		txtBKNO.value           = rsData("BKNO")
		txtPGNO.value           = rsData("PGNO")
		txtDISP.value           = rsData("DISP")
		txtDISPDT.value         = rsData("DISPDT")
		
		rsData.MoveNext
	Loop
		
		strHTML = strHTML & "<tr>"
		strHTML = strHTML & "<td>" & txtName & "</td>"
		strHTML = strHTML & "<td>" & txtREL & "</td>"	
		strHTML = strHTML & "<td>" & txtESTNO & "</td>"
		strHTML = strHTML & "<td>" & txtDTFILD & "</td>"
		strHTML = strHTML & "<td>" & txtPUB & "</td>"
		strHTML = strHTML & "<td>" & txtTypeOfDocument & "</td>"
		strHTML = strHTML & "<td>" & txtBTYP & "</td>"
		strHTML = strHTML & "<td>" & txtBKNO & "</td>"
		strHTML = strHTML & "<td>" & txtPGNO & "</td>"
		strHTML = strHTML & "<td>" & txtDISP & "</td>"
		strHTML = strHTML & "<td>" & txtDISPDT & "</td>"
		strHTML = strHTML & "</tr>"
		
	strHTML2 = strHTML2 & "</table>"
	searchIT.innerHTML = strHTML2

end sub

</script>
<style>
<!--
fieldset     { border: 1 solid #000080 }
font         { font-family: Verdana; font-size: 10pt }
-->
</style>
</head>

<body onload="dotheconnection" language="vbscript">
<font face="Verdana" size="2">


<div align=center><input type="button" value="Search Database" onClick="expandcontent('sc2')" style="font-size: 12px; font-family: Arial; background-color: #000080; color: #FFECFF"></div>
<div id="sc1" class="switchcontent">

<div align="left">
  <table border="0" width="700" height="16">
    <tr>
      <td width="294" height="8"><input type="hidden" name="txtName" size="43"></td>
      <td width="294" height="10"><input type="hidden" name="txtREL" size="8"></td>
      <td width="294" height="85"><input type="hidden" name="txtEstno"></td>
      <td width="294" height="85"><input type="hidden" name="txtDTFILD"></td>
      <td width="294" height="85"><input type="hidden" name="txtPUB"></td>
      <td width="294" height="85"><input type="hidden" name="txtTypeOfDocument"></td>
      <td width="294" height="85"><input type="hidden" name="txtBTYP"></td>
      <td width="294" height="85"><input type="hidden" name="txtBKNO"></td>
      <td width="294" height="85"><input type="hidden" name="txtPGNO"></td>
      <td width="294" height="85"><input type="hidden" name="txtDISP"></td>
      <td width="294" height="85"><input type="hidden" name="txtDISPDT"></td>
    </tr>
    <tr>
      <td width="318" height="5" align="right">
   </td>
  </tr>
  </table>
</div>
</div>
<div id="sc2" class="switchcontent">

<div align="center">
 <table border="0" width="627" height="16">
    <tr>
      <td width="126" height="8" align="right">
     <b><font color="#000080" size="2" face="Verdana">Search :</font></b></td>
     <td width="487" height="8"><b><font face="Verdana" size="2"><input type="text" name="txtsrch" size="43"></font></b><input type="button" name="btnSearch" value="Search" onclick="searchdata" language="vbscript" style="background-color: #000080; color: #FFECFF; font-family: Verdana; font-size: 10px">
      </td>
      </tr><tr><td width="126"></td><td width="487"><b><font color="#000080" size="2" face="Verdana">
        You can search by any name e.g.; Gibbs</font></b>
      </td>
    </tr>
     </table>
</div>

<fieldset>
<legend><b><font face="Verdana" size="2">Search Results.</font></b></legend>
<center><div style="width: 600; height: 100; overflow: auto; border: 0px solid black" id="searchIT"></div>
</center>
</fieldset>
</script>

Open in new window

LVL 29
sammySeltzerAsked:
Who is Participating?
 
khairilConnect With a Mentor Commented:
OR much more better...

=================
      Do Until rsData.EOF
            strHTML = strHTML") & "<tr>"
            strHTML = strHTML") & "<td>" & rsData("Name") & "</td>"
            strHTML = strHTML") & "<td>" & rsData("REL") & "</td>"      
            strHTML = strHTML") & "<td>" & rsData("ESTNO") & "</td>"
            strHTML = strHTML") & "<td>" & rsData("DTFILD") & "</td>"
            strHTML = strHTML") & "<td>" & rsData("PUB") & "</td>"
            strHTML = strHTML") & "<td>" & rsData("TypeOfDocument") & "</td>"
            strHTML = strHTML") & "<td>" & rsData("BTYP") & "</td>"
            strHTML = strHTML") & "<td>" & rsData("BKNO") & "</td>"
            strHTML = strHTML") & "<td>" & rsData("PGNO") & "</td>"
            strHTML = strHTML") & "<td>" & rsData("DISP") & "</td>"
            strHTML = strHTML") & "<td>" & rsData("DISPDT") & "</td>"
            strHTML = strHTML") & "</tr>"

            rsData.MoveNext
      Loop

========================

AND remove the hidden fields... unless you have something else to do with it.

regards.
0
 
khairilCommented:
Hi,

Try fix this in searchdata sub...

      strHTML2 = strHTML2 & "</table>"
      searchIT.innerHTML = strHTML2


TO

      strHTML2 = strHTML2 & strHTML & "</table>"
      searchIT.innerHTML = strHTML2


Regards.
0
 
khairilCommented:
BTW, your loop doesn't seems right..

I think this one is much more better.. else you will only get last record.

==========================================================

      Do Until rsData.EOF
            txtNAME.value           = rsData("NAME")
            txtREL.value            = rsData("REL")
            txtESTNO.value          = rsData("ESTNO")
            txtDTFILD.value         = rsData("DTFILD")
            txtPUB.value            = rsData("PUB")
            txtTypeOfDocument.value = rsData("TYPEOFDOCUMENT")
            txtBTYP.value           = rsData("BTYP")
            txtBKNO.value           = rsData("BKNO")
            txtPGNO.value           = rsData("PGNO")
            txtDISP.value           = rsData("DISP")
            txtDISPDT.value         = rsData("DISPDT")
            
            
            strHTML = strHTML & "<tr>"
            strHTML = strHTML & "<td>" & txtName & "</td>"
            strHTML = strHTML & "<td>" & txtREL & "</td>"      
            strHTML = strHTML & "<td>" & txtESTNO & "</td>"
            strHTML = strHTML & "<td>" & txtDTFILD & "</td>"
            strHTML = strHTML & "<td>" & txtPUB & "</td>"
            strHTML = strHTML & "<td>" & txtTypeOfDocument & "</td>"
            strHTML = strHTML & "<td>" & txtBTYP & "</td>"
            strHTML = strHTML & "<td>" & txtBKNO & "</td>"
            strHTML = strHTML & "<td>" & txtPGNO & "</td>"
            strHTML = strHTML & "<td>" & txtDISP & "</td>"
            strHTML = strHTML & "<td>" & txtDISPDT & "</td>"
            strHTML = strHTML & "</tr>"

            rsData.MoveNext
      Loop

============================================

regards.
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
sammySeltzerAuthor Commented:
Thanks much khairil:

Almost there.

However, I am getting weird data.

Each row of data says [object]

and also, when I remove the hidden fields, I get

 "Line: 152 Error: Object required: 'txtNAME'

And if I remove txtName, then the error is on next line.

Any ideas what else needs fixing?

Again, thanks a lot
0
 
sammySeltzerAuthor Commented:
I got that figured out.

Everything works great now.

Thanks a lot for your assistance.
0
 
khairilCommented:
Thanks, hope the best for you then.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.