I am currently working with an HTML file structured like this..
<html>
<body>
<table border="1" cellpadding="5">
<tr>
<td>Some Fixed text here</td>
<td id="data">---here data as per values in external text file---</td>
</tr>
</table>
</html>
Within the same directory, I have a text file called data.txt alongside the index.html file.
My goal is to use scripts to read the text file and place specific innerHTML content in the id=data based on the values in the first character of the text file.
For example,
for 0 in the first character, innerHTML=
<div style="color:red; border:2px dotted blue;">Alpha</div>
for 1 in the first character, innerHTML=<div>Beta</div>
for 2 in the first character, innerHTML=
<div>Gamma<span>more text</span></div>
and so on...
I have attempted to implement various scripts using jQuery and AJAX, but they have not provided the desired results. Due to my limited knowledge of these technologies, I am struggling to identify the issue. Is there anyone who can assist me in creating a script using JavaScript or a similar language?