Solved

working with HTA

Posted on 2010-08-31
6
265 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
ID: 33571088
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
ID: 33571128
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
ID: 33571195
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 28

Author Comment

by:sammySeltzer
ID: 33572700
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
ID: 33572859
I got that figured out.

Everything works great now.

Thanks a lot for your assistance.
0
 
LVL 13

Expert Comment

by:khairil
ID: 33573497
Thanks, hope the best for you then.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Make a file test.vbs using vbscript 5 63
how to add fields in script 20 51
ASP Focus problem 3 51
fso.FolderExists("\\server\HiddenFolder$") 4 49
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

919 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

14 Experts available now in Live!

Get 1:1 Help Now