本文介绍了输入TextArea和输出TextArea并保存到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经通过按钮编写了一份快速操作手册,以进行快速操作:复制到剪贴板,消息框并运行特定文件.现在,我正在尝试弄清楚如何添加:
I've written up a quick hta for quick actions via button: copy to clipboard, message boxes, and run specific files. Now I'm trying figure out how to add:
2个文本框
- TextArea1-在文本框中输入文字
- 提交按钮以将textarea1保存到本地文件并加载到textarea2
- TextArea2-将显示来自textarea1的已保存本地文件中的文本
感谢您的时间和考虑
<html>
<head>
<title>**All Access QL v1.0**</title>
<HTA:APPLICATION
ID="TestHTA"
APPLICATIONNAME="TestHTA"
ICON = "C:\L.S.L._QL_HTAv1.0\Media\RazerIcon.ico"
BORDER="thin"
MINIMIZEBUTTON="no"
MAXIMIZEBUTTON="no"
SCROLL="no"
SINGLEINSTANCE="no"
SysMenu="no"
WINDOWSTATE="normal">
<link rel="stylesheet" href="styles.css" media="all" type="text/css"/>
<SCRIPT LANGUAGE="VBScript">
Sub Window_onLoad
window.resizeTo 510,510
End Sub
Sub ExitProgram
window.close()
End Sub
Sub fileupdate
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\CopyFromLocation1","C:\CopyToLocation1", True
End Sub
Sub lotsiu
strMessage = "Line 1" & vbNewLine & "Line 2"
Set objWord = CreateObject("Word.Application")
With objWord
.Visible = False
.Documents.Add
.Selection.TypeText strMessage
.Selection.WholeStory
.Selection.Copy
.Quit False
End With
End Sub
Sub faqmbrPhonumuse
msgbox "Line 1" & vbNewLine & "Line 2"
End Sub
Sub appword
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "WINWORD.exe"
End Sub
sub Window_onLoad()
set oFSO=CreateObject("Scripting.FileSystemObject")
set oFile=oFSO.OpenTextFile("Test.txt",1)
text=oFile.ReadAll
document.all.ScriptArea.value=text
oFile.Close
End sub
Sub Submitarea
Set oFile = fso.OpenTextFile( "TextArea.txt",8,true)
sTxtarea = document.all("Txtarea").Value
oFIle.Write sTxtarea & vbCRLF
MsgBox "Your text has been added to TextArea.txt", 64,"Textarea Input"
oFile.close
End Sub 'Submitarea
</SCRIPT>
</head>
<body>
<div id="Title">
<b>PSC Quick Access</b>
<input id="checkButton" class="upbutton" type="button" value="UPDATE" name="run_button" onClick="fileupdate" align="right">
<input id="checkButton" class="upbutton" type="button" value="EXIT" name="run_button" onClick="ExitProgram" align="right">
</div>
<div id="SubTitle">
Email- Phone Number
</div>
<div id="Icon">
</div>
<br>
<div id="ContentBox">
<b>Fax Temps (Click and Paste)</b>
</div>
<input id="checkButton" class="faxbutton" type="button" value="Button 1" name="btn_Next" onClick="button1" align="right">
<br>
<div id="ContentBox">
<b>Apps (Click To Start)</b>
</div>
<input id="checkButton" class="appbutton" type="button" value="Notepad" name="run_button" onclick="appnotepad" align="right">
<input id="checkButton" class="appbutton" type="button" value="Word" name="run_button" onClick="appword" align="right">
<br>
<div id="ContentBox">
<b>FAQs (Click for Info)</b>
</div>
<input id="checkButton" class="faqbutton" type="button" value="Num For Mbr" name="run_button" onClick="faqmbrPhonumuse" align="right">
<br>
<div id="ContentBox">
<b>Lotus Temps (Click and Paste)</b>
</div>
<input id="checkButton" class="lotbutton" type="button" value="SIU" name="btn_Next" onClick="lotsiu" align="right">
</div>
<form method="POST">
<TEXTAREA style="
Height:193;
Width:100%;
font-Size:12;
color:#000000;
background-color:#ffffe7;
font-weight:normal;
font-family:MS Sans Serif"
TITLE=""
NAME=Txtarea TABORDER=2 WRAP=PHYSICAL>The contents of this text area will be written to C:\TextArea.doc when you click submit.******First time submit is click if file has not been created it will be create automatically daily log with system date appended at the end******and will append data to top of file with prefix of system time******Line at end of margin will have hard return when text is at the end******And get and display new changed text in the lower text box and diplayed******Lower textarea has scroll and can be highlighted, but not editable"</TEXTAREA>
<input type="button" value="Submit" onclick="Submitarea">
<input type="reset" value="Clear">
<br><br>
<textarea name="ScriptArea" rows=10 cols=70></textarea><p>
</div>
</body>
推荐答案
2015年9月3日:尝试类似的方法:
<html>
<Title>How to open and read the log file with HTA</Title>
<head>
<HTA:APPLICATION
ICON="cmd.exe"
APPLICATIONNAME = "How to open and read the log file with HTA"
BORDER="dialog"
BORDERSTYLE="complex"
WINDOWSTATE="maximize"
>
<style>
body{
background-color: Black;
}
</style>
</head>
<script type="text/Vbscript">
Option Explicit
Dim File,fso,oFile,objShell
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
File = "C:\Test_" _
& Month(Date) & "_" & Day(Date) & "_" & Year(Date) _
& ".txt"
'***********************************************************
Sub LoadMyFile()
txtBody.Value = LoadFile(File)
End Sub
'***********************************************************
Function LoadFile(File)
On Error Resume Next
Dim fso,F,ReadMe,strError
Set fso = CreateObject("Scripting.FileSystemObject")
Set F = fso.OpenTextFile(File,1)
If Err.Number <> 0 Then
strError = "<center><b><font color=Red>The file "& File &" dosen't exists !</font></b></center>"
myDiv.InnerHTML = strError
Exit Function
End If
ReadMe = F.ReadAll
LoadFile = ReadMe
End Function
'***********************************************************
Sub Clear()
txtBody.Value = ""
myDiv.InnerHTML = ""
Txtarea.Value = ""
End Sub
'***********************************************************
Function LogOpen()
Dim Ws,iReturn,strError
Set ws = CreateObject("WScript.Shell")
On Error Resume Next
iReturn = Ws.Run(File,1,False)
If Err.Number <> 0 Then
strError = "<center><b><font color=Red>The file "& File &" dosen't exists !</font></b></center>"
myDiv.InnerHTML = strError
Exit Function
End If
End Function
'***********************************************************
Sub Submitarea()
Dim oFile,sTxtarea,Readfile,ReadAllTextFile,strError
If Not fso.FileExists(File) Then
Set oFile = fso.OpenTextFile(File,2,true)
oFIle.write "The File "& File &" is created at " & FormatDateTime(now,vbLongTime)
oFile.Close
End If
Set Readfile = fso.OpenTextFile(File,1)
ReadAllTextFile = Readfile.ReadAll
Set oFile = fso.OpenTextFile(File,2,true)
sTxtarea = document.all("Txtarea").Value
oFIle.Writeline
oFIle.write ("Name ")
oFIle.write FormatDateTime(now, 2)
oFIle.write (" ")
oFIle.write FormatDateTime(now,vbLongTime)
'FormatDateTime(now, 4)
oFIle.write (" - ")
oFIle.Write sTxtarea & vbCrLf
oFIle.WriteLine ReadAllTextFile
myDiv.InnerHTML = "Your text has been added to "& File &""
oFile.Close
Call LoadMyFile()
End Sub
'***********************************************************
</script>
<body text="white">
<center><input type="button" name="Log" id="Start" value=" Load LogFile " onclick="LoadMyFile()"><br><br>
<textarea id="txtBody" rows="15" cols="120"></textarea><br><br>
<input type="button" name="Log" id="Start" value=" Open LogFile with Notepad " onclick="LogOpen()">
<input type="button" value=" Clear " onclick="Clear()"></center>
<Div id="myDiv"></Div>
<br><br>
<TEXTAREA style="
Height:193;
Width:100%;
font-Size:12;
color:#000000;
background-color:#ffffe7;
font-weight:normal;
font-family:MS Sans Serif"
TITLE=""
ID="Txtarea" NAME="Txtarea" TABORDER="2" WRAP="PHYSICAL">The contents of this text area will be written to TextArea.txt when you click submit.</TEXTAREA><br><br>
<center><input type="button" value="Submit" onclick="Submitarea">
<input type="reset" value="Reset"></center>
</body>
</html>
这篇关于输入TextArea和输出TextArea并保存到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!