Hi,
I am sorry if this is not the most appropriate group to ask this in
(if not, please
point me in the right direction). I am following examples from this page,
http://www.vbwm.com/articles/2002/abarfield/hta01/
I have a some questions about Figure 5 (below). This hta file will view a
text file when a button is pushed.
1. Why do the paths require double '\' ? like
F:\documents\random text\realpongfaq.txt needs to be
F:\\documents\\random text\\realpongfaq.txt
2. How would i store the path as a variable instead
of putting it directly in the BUTTON tag
<BUTTON style= "border: 1px outset; width:100px"
onClick="ReadFile('c:\\autoexec.bat');">
Read File
</BUTTON>
instead do something like (which doesn't work)
var filePath = 'F:\\documents\\random text\\realpongfaq.txt'
<BUTTON style= "border: 1px outset; width:100px"
onClick="ReadFile(filePath);">
Read File
</BUTTON>
3. How can I creat a File Field form to select the file instead
of hard coding the path? similar to this to select the file.
http://largebuttons.com/fileupload.htm
Thanks,
Chuck
Figure 5
<HTML>
<HEAD>
<TITLE>Read File</TITLE>
<HTA:APPLICATION
ID = "oApp"
APPLICATIONNAME = "My HTA App 2001"
BORDER = "thick"
CAPTION = "yes"
ICON = "app.ico"
SHOWINTASKBAR = "yes"
SINGLEINSTANCE = "yes"
SYSMENU = "yes"
WINDOWSTATE = "normal"
SCROLL = "yes"
SCROLLFLAT = "yes"
VERSION = "1.0">
<SCRIPT Language="JScript">
function ReadFile(filename)
{
var fso, f;
var ForReading = 1;
fso = new ActiveXObject(
"Scripting.FileSystemObject");
f = fso.OpenTextFile(filename,
ForReading);
txtbox.innerText = f.ReadAll();
}
</SCRIPT>
</HEAD>
<BODY scroll="no" style=
"background:buttonface; color:buttontext;
border:0px; padding:0px; margin:0px">
<table cellspacing=0 cellpadding=0
border=0 width=100% height=100%>
<tr>
<td height=4></td>
</tr>
<tr>
<td height=20>
<BUTTON style=
"border: 1px outset;
width:100px"
onClick="ReadFile(
'c:\\autoexec.bat');">
Read File</BUTTON>
</td>
</tr>
<tr>
<td height=4></td>
</tr>
<tr>
<td>
<div id="txtbox" style=
"overflow:scroll;
background:window;
border: 1px inset;
font: 8pt Arial; width:100%;
height:100%"></div>
</td>
</tr>
</table>
<OBJECT ID="oShell" CLASSID=
"clsid:13709620-C279-11CE-
A49E-444553540000">
</OBJECT>
</BODY>
</HTML>