This is my HTML code. I would like to read the temperatures from a locally-stored *.txt file and replace the div content with the value read from *.txt file.
<div class="floortitle">Temperaturen</div>
<div class='tempfield'>
<div class='picpos'><img src='heating.gif'></div>
<div style="position:absolute; top: 255px; left: 65px;">
<div class='tempbox' id='Temp1'>11°C</div>
</div>
<div style="position:absolute; top: 255px; left: 102px;">
<div class='tempbox' id='Temp2'>12°C</div>
</div>
<div style="position:absolute; top: 151px; left: 145px;">
<div class='tempbox' id='Temp3'>13°C</div>
</div>
.
.
. till Temp 6
.
</div>
The content of the *.txt file looks like this.
02.10.2013;17:40:59;Temp 1;17;
02.10.2013;17:40:59;Temp 2;27;
02.10.2013;17:40:59;Temp 3;34;
02.10.2013;17:40:59;Temp 4;46;
02.10.2013;17:40:59;Temp 5;53;
02.10.2013;17:40:59;Temp 6;61;
But the result could also start with Temp 4,5,6,1,2,3 depends of when measuring is done in time page is refreshed. To prepare the *.txt file, I use a simple tail -6 originallog.txt
I think this can be done with JavaScript, but when I search the Internet, I always find results to just output the results, without searching for String and matching to a corresponding div.
The following steps should be done:
- Open *.txt file and read content
- Search for Temp 1 to Temp 6 --> loop with something like
document.getElementById('Temp $i')