谁能给一个将txt文件导入文本框的jsp代码,谢谢!
1个回答
展开全部
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>导入效果</title>
<script language="JavaScript">
function loadFile()
{
if(document.form1.file.value=="")
{
alert("请先选择文件!");
return false;
}
else
{
// document.form1.but1.startDownload(document.form1.file.value,onDownloadDone)
onDownloadDone();
}
}
function onDownloadDone()
{
var obj = new ActiveXObject("Scripting.FileSystemObject");
var f = obj.OpenTextFile(document.form1.file.value, 1, true);
var data = f.ReadAll();
document.form1.tt2.value=data;
}
</script>
</head>
<body>
<form name="form1" method="post" action="">
<p>
<input type="file" name="file" id="file">
<input name="but1" type="button" id="but1" style="behavior:url(#default#download)" onClick="loadFile()" value="OK!确定">
<br>
<br>
<textarea name="tt2" cols="50" rows="10" id="tt2"></textarea>
</p>
</form>
<p> </p>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>导入效果</title>
<script language="JavaScript">
function loadFile()
{
if(document.form1.file.value=="")
{
alert("请先选择文件!");
return false;
}
else
{
// document.form1.but1.startDownload(document.form1.file.value,onDownloadDone)
onDownloadDone();
}
}
function onDownloadDone()
{
var obj = new ActiveXObject("Scripting.FileSystemObject");
var f = obj.OpenTextFile(document.form1.file.value, 1, true);
var data = f.ReadAll();
document.form1.tt2.value=data;
}
</script>
</head>
<body>
<form name="form1" method="post" action="">
<p>
<input type="file" name="file" id="file">
<input name="but1" type="button" id="but1" style="behavior:url(#default#download)" onClick="loadFile()" value="OK!确定">
<br>
<br>
<textarea name="tt2" cols="50" rows="10" id="tt2"></textarea>
</p>
</form>
<p> </p>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询