Login | |
|
 |
Dynamic List Box Question - 1/14/2008 8:43:12 PM
|
|
 |
|
| |
patgenn123
Posts: 37
Score: 0
Joined: 1/14/2008
Status: offline
|
Greetings everyone! I am very new to HTML/HTA etc. Very new and don't understand it that much yet. It will take me some time. I am interested in a dynamic list box that pulls info from a text file. After it does that, I would like to be able to "click on an item from the list and then search the text box for a matching item. The text file is tab delimited and has name, address, city state, zip, and phone number and is constantly being added to via the same hta. I would like to: a) click on the list box. (The list box only has the person's name) b) search for the line in the text file c) Fill in the fields corresponding to the clicked name in the list box I found this on Microsoft's website and want to know how to modify this and make it work: Sub Window_OnLoad ForReading = 1 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile _ ("C:\Documents and Settings\Pat\Desktop\ReadMe.txt", ForReading) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine Set objOption = Document.createElement("OPTION") objOption.Text = strLine objOption.Value = strLine AvailableComputers.Add(objOption) Loop objFile.Close End Sub </SCRIPT> <body> <select size="20" name="AvailableComputers" style="width:250"></select> </body> Keep in mind, I have absolutely no idea what a lot of these things mean. I am starting to get some things, but it will take a while. Also, remember, this is HTA. Thank You! Pat
|
|
| |
|
|
|
 |
RE: Dynamic List Box Question - 1/14/2008 9:39:01 PM
|
|
 |
|
| |
patgenn123
Posts: 37
Score: 0
Joined: 1/14/2008
Status: offline
|
ehvbs, I don't know if I want to post the .hta code. It's my very first one and it has a lot of "experimental things in it. Yet, if you do want it, here it is: <title>HTA Test</title> <HTA:APPLICATION APPLICATIONNAME="HTA Test" SCROLL="no" SINGLEINSTANCE="yes" WINDOWSTATE="normal" <HTA:APPLICATION NAVIGABLE = "yes" /> > </head> <script language="VBScript"> Sub Window_Onload strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor") For Each objItem in colItems intHorizontal = objItem.ScreenWidth intVertical = objItem.ScreenHeight Next intLeft = (intHorizontal - 700) / 2 intTop = (intVertical - 600) / 2 window.resizeTo 800,600 window.moveTo intLeft, intTop End Sub Sub SaveData //////////////////Deletes what is in the text file FIRST before adding new information to the tabbed text values//////////////////////// Const ForWriting = 2 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.tsv", ForWriting) objFile.Write "" objFile.Close ////////////// ends///////////////// Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FileExists("C:\Scripts\Test.tsv") Then Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.tsv", 8) strLine = UserName.Value & vbTab & Email.Value & vbTab & _ Title.Value & vbTab & Country.Value & vbTab & Product.Value & vbTab & DropDown1.Value & vbTab & BasicTextBox.Value & vbTab & BasicTextArea.Value objFile.WriteLine strLine objFile.Close Else Set objFile = objFSO.CreateTextFile("C:\Scripts\Test.tsv") strLine = UserName.Value & vbTab & Email.Value & vbTab & _ Title.Value & vbTab & Country.Value & vbTab & Product.Value &vbTab & DropDown1.Value & vbTab & BasicTextBox.Value & vbTab & BasicTextBox.Value objFile.WriteLine strLine objFile.Close End If End Sub Sub SetFullName CombinedName.Value = FirstName.Value & " " & LastName.Value End Sub Sub TestSub Msgbox "Testing 1-2-3." End Sub Sub Window_onLoad window.resizeTo 700,600 End Sub Sub Runone strCopy = DropDown1.Value document.parentwindow.clipboardData.SetData "text", strCopy End Sub Sub RunScript strCopy = BasicTextArea.Value document.parentwindow.clipboardData.SetData "text", strCopy End Sub Sub DateDiff Set objShell = CreateObject("Wscript.Shell") objShell.Run "DateDiff.mxe" End Sub Sub RunScript1 strAnswer = window.prompt("Please enter the domain name.", "fabrikam.com") If IsNull(strAnswer) Then Msgbox "You clicked the Cancel button" Else Msgbox "You entered: " & strAnswer End If End Sub </script> <body> <button onclick="DateDiff">Run Date Difference</button> <p> <a href ="scared.hta">Go to Scared</a> <body bgcolor="IndianRed"> <textarea name="BasicTextArea" rows="7" cols="45"></textarea> <input type="button" value="Copy to Clipboard" name="run_button" onClick="RunScript"><p> <input type="button" value="Run Script" name="run_button" onClick="TestSub"> <input type="button" value="Run Script" name="run_button" onClick="RunScript1"> <input type="text" name="BasicTextBox" size="50"><p> <br>Copy to Clipboard</br> <select size="3" name="DropDown1" onChange="Runone"> <option value="1">Option 1</option> <option value="2">Option 2</option> <option value="3">Option 3</option> <option value="4">Option 4</option> </select> <h2>First Name Last Name, Full Name </h2> <input type="text" name="FirstName" size="15" onChange="SetFullName"> <input type="text" name="LastName" size="15" onChange="SetFullName"> <input type="text" name="CombinedName" size="25" readOnly=True> <h1> User name, Text etc.</h1> <input type="text" name="UserName" size="15"><input type="text" name="Email" size="15" ><input type="text" name="Title" size="15"><input type="text" name="Country" size="15"><input type="text" name="Product" size="15"> <input type="button" value="Run Button" onClick="SaveData"> <input type="button" value="Run Button" onClick="DateDiff"> <A HREF="Microsoft'>http://www.microsoft.com/ie/ie40/demos">Microsoft </A> has some wonderful stuff! </body> </html>
|
|
| |
|
|
|
 |
RE: Dynamic List Box Question - 1/15/2008 5:12:43 AM
|
|
 |
|
| |
Rischip
Posts: 468
Score: 2
Joined: 3/26/2007
Status: offline
|
It's just my opinion, but I think this would be much shorter code if you look at the file like a database. Open the text file using ADODB and treat each entry like a recordset. You could still do a dynamic listbox to jump to an individual record and begin editing it.
< Message edited by Rischip -- 1/15/2008 5:14:28 AM >
_____________________________
Rischip Author of - The Grim Linker
|
|
| |
|
|
|
 |
RE: Dynamic List Box Question - 1/15/2008 8:18:08 AM
|
|
 |
|
| |
Rischip
Posts: 468
Score: 2
Joined: 3/26/2007
Status: offline
|
Are the headers in the text file? i.e. FirstName LastName Street City John Doe 121 Anywhere Street Austin Texas 75709 or is it just the data? i.e. John Doe 121 Anywhere Street Austin Texas 75709
_____________________________
Rischip Author of - The Grim Linker
|
|
| |
|
|
|
 |
RE: Dynamic List Box Question - 1/16/2008 2:51:05 AM
|
|
 |
|
| |
Rischip
Posts: 468
Score: 2
Joined: 3/26/2007
Status: offline
|
I'm fine with any changes I adapted this code from Microsoft's website. I will reference the page once I find it again.
_____________________________
Rischip | | |