OK, so I'm trying to monitor and control something with a Pic-web from microchip. I managed to program it all except for one thing. I need to compare two temperatures that it gives me, and if one of them is smaller that the other then a relay needs to be activated, if its bigger or equal then another relay must be activated. From what I understood Pic-web updates an xml file (status.xml) then the website (using ajax) takes the values from there and displays them on the web page.
The XML file looks like this
<response>
<temp0>~temp~</temp0>
<temp2>~tempc~</temp2>
</response
The ajax code I use to get the values in my web page
document.getElementById('temp0').innerHTML = getXMLValue(xmlData, 'temp0');
document.getElementById('temp2').innerHTML = getXMLValue(xmlData, 'temp2');
And to display them I use
<span id="temp0"style="font-weight:normal">?</span>
<span id="temp2"style="font-weight:normal">?</span>
All I need to do is to compare temp0 with temp2
var temp0 = parseFloat(document.getElementById('temp0').innerHTML)
var temp2 = parseFloat(document.getElementById('temp2').innerHTML)
if( temp0 < temp2 )
{
document.getElementById('temp3').innerHTML = '<font color="#00FF00">ON</font>';
}
else
{
document.getElementById('temp3').innerHTML = '<font color="#00FFFF">OFF</font>';
}
The I just add <span id="temp3">?</span> to display the result
Am I correct?