Solved

working with HTA

Posted on 2010-08-31
6
264 Views
Last Modified: 2012-08-14
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

0
Comment
Question by:sammySeltzer
  • 4
  • 2
6 Comments
 
LVL 13

Expert Comment

by:khairil
Comment Utility
Hi,

Try fix this in searchdata sub...

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


TO

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


Regards.
0
 
LVL 13

Expert Comment

by:khairil
Comment Utility
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
 
LVL 13

Accepted Solution

by:
khairil earned 250 total points
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 28

Author Comment

by:sammySeltzer
Comment Utility
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
 
LVL 28

Author Comment

by:sammySeltzer
Comment Utility
I got that figured out.

Everything works great now.

Thanks a lot for your assistance.
0
 
LVL 13

Expert Comment

by:khairil
Comment Utility
Thanks, hope the best for you then.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now