如何從使用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 –
要讀取本地文本文件? –
澄清要求..你打算在客戶端文件搜索或在服務器端文件搜索? –