如何从使用JavaScript的文本文件中提取文本数据?我正在制作一本在线字典。我可以编写HTML和CSS,但不是JavaScript。使用javascript从文本文件中提取数据
单词将在第一个文本框中输入,然后搜索按钮将被点击,结果将显示在底部的文本框中。 文本文件中的数据类似于“apple | a juicy fruit” (不含引号“ 现在我希望搜索字段中的文本检查”|“符号前面的单词,如果发现匹配单词/单词后面的”| | ?“将被发送到结果字段 我怎样才能做到这一点使用JavaScript
我对项目的HTML代码如下:
<html>
<head>
<title>Online Dictionary</title>
<style>
.field{
border: 2px solid black;
}
#result_field{
margin-top: 5px;
width: 247px;
height: 100px;
}
</style>
</head>
<body>
<input type="text" placeholder="Enter your word here..." name="search_field" id="search_field" class="field">
<input type="button" value="SEARCH" name="btn" id="btn" class="btn"> <br>
<input type="text" placeholder="Meaning here..." name="result_field" id="result_field" class="field">
</body>
</html>
,你将不得不使用PHP –
要读取本地文本文件? –
澄清要求..你打算在客户端文件搜索或在服务器端文件搜索? –