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,
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\ra ndom text\realpongfa q.txt needs to be
F:\\documents\\ random text\\realpongf aq.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="ReadFi le('c:\\autoexe c.bat');">
Read File
</BUTTON>
instead do something like (which doesn't work)
var filePath = 'F:\\documents\ \random text\\realpongf aq.txt'
<BUTTON style= "border: 1px outset; width:100px"
onClick="ReadFi le(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.
Thanks,
Chuck
Figure 5
<HTML>
<HEAD>
<TITLE>Read File</TITLE>
<HTA:APPLICATIO N
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="JScri pt">
function ReadFile(filena me)
{
var fso, f;
var ForReading = 1;
fso = new ActiveXObject(
"Scripting.File SystemObject");
f = fso.OpenTextFil e(filename,
ForReading);
txtbox.innerTex t = f.ReadAll();
}
</SCRIPT>
</HEAD>
<BODY scroll="no" style=
"background:but tonface; color:buttontex t;
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="ReadFi le(
'c:\\autoexec.b at');">
Read File</BUTTON>
</td>
</tr>
<tr>
<td height=4></td>
</tr>
<tr>
<td>
<div id="txtbox" style=
"overflow:scrol l;
background:wind ow;
border: 1px inset;
font: 8pt Arial; width:100%;
height:100%"></div>
</td>
</tr>
</table>
<OBJECT ID="oShell" CLASSID=
"clsid:1370 9620-C279-11CE-
A49E-444553540000">
</OBJECT>
</BODY>
</HTML>
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,
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\ra ndom text\realpongfa q.txt needs to be
F:\\documents\\ random text\\realpongf aq.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="ReadFi le('c:\\autoexe c.bat');">
Read File
</BUTTON>
instead do something like (which doesn't work)
var filePath = 'F:\\documents\ \random text\\realpongf aq.txt'
<BUTTON style= "border: 1px outset; width:100px"
onClick="ReadFi le(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.
Thanks,
Chuck
Figure 5
<HTML>
<HEAD>
<TITLE>Read File</TITLE>
<HTA:APPLICATIO N
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="JScri pt">
function ReadFile(filena me)
{
var fso, f;
var ForReading = 1;
fso = new ActiveXObject(
"Scripting.File SystemObject");
f = fso.OpenTextFil e(filename,
ForReading);
txtbox.innerTex t = f.ReadAll();
}
</SCRIPT>
</HEAD>
<BODY scroll="no" style=
"background:but tonface; color:buttontex t;
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="ReadFi le(
'c:\\autoexec.b at');">
Read File</BUTTON>
</td>
</tr>
<tr>
<td height=4></td>
</tr>
<tr>
<td>
<div id="txtbox" style=
"overflow:scrol l;
background:wind ow;
border: 1px inset;
font: 8pt Arial; width:100%;
height:100%"></div>
</td>
</tr>
</table>
<OBJECT ID="oShell" CLASSID=
"clsid:1370 9620-C279-11CE-
A49E-444553540000">
</OBJECT>
</BODY>
</HTML>
Comment