Или так (попроще и еще корявее ;)
<HTML>
<HEAD>
<title>Simplex Web</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1251">
<meta name="viewport" content="height=device-height, initial-scale=1.0">
<script type="text/javascript">
function Work_data(str)
{
var table = document.getElementById('mytab');
var trList= table.getElementsByTagName('tr');
var temp = new Array();
var temp2 = new Array();
temp = str.split(';');
for (var i = 1; i < 10; i++)
{
temp2 = temp[i-1].split(',');
var tdList = trList[i].getElementsByTagName('td');
if(temp2[0]=='0') // not present
{
tdList[1].style.backgroundColor = '#000000'; //left perim
tdList[3].style.backgroundColor = '#000000'; //right perim
tdList[2].innerHTML = '<font face="Arial, Helvetica, sans-serif"><font size="5"><font color="#000000"> </font></font></font>';
}
else // present
{
/// ves
if (temp2[1]=='0') // not stab
tdList[2].innerHTML = '<font face="Arial, Helvetica, sans-serif"><font size="5"><font color="#FF0000">'+temp2[6]+'</font></font></font>';
else tdList[2].innerHTML = '<font face="Arial, Helvetica, sans-serif"><font size="5"><font color="#00FF00">'+temp2[6]+'</font></font></font>';
// ves registr
if (temp2[2]=='1') tdList[2].innerHTML = '<font face="Arial, Helvetica, sans-serif"><font size="5"><font color="##00FFFF">'+temp2[6]+'</font></font></font>';
// perimeter
if (temp2[5]=='1') // perimeter OFF
{
tdList[1].style.backgroundColor = '#9C9C9C'; //left perim GRAY
tdList[3].style.backgroundColor = '#9C9C9C'; //right perim GRAY
}
else
{
if (temp2[3]=='1') tdList[1].style.backgroundColor = '#FF0000'; //left perim RED
else tdList[1].style.backgroundColor = '#008B00'; //left perim Green
if (temp2[4]=='1') tdList[3].style.backgroundColor = '#FF0000'; //right perim RED
else tdList[3].style.backgroundColor = '#008B00'; //right perim Green
}
}
}
}
function GetData(m)
{
nocache = "&nocache="+ Math.random() * 1000000;
var xmlhttp;
if (window.XMLHttpRequest)
{// код для IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// код для IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
Work_data(xmlhttp.responseText);
}
}
xmlhttp.open("GET",("***"+m),true);
xmlhttp.send();
}
var timerId = setInterval(function(){GetData('0');}, 500); //
</script>
</HEAD>
<body>
<p align="center"><font face="Arial, Helvetica, sans-serif"><font size="4">Весовые платформы</font></font></p>
<table id="mytab" align="center" border="2" cellpadding="2" cellspacing="2" height="20" width="250">
<tr>
<td style="width: 10px; text-align: center;"><font size="4">N</font></td>
<td colspan="3" rowspan="1" style="width: 5px; text-align: center;"><font size="4">Весы</font></td>
<td style="width: 30px; text-align: center;"><font size="4">Периметр</font></td>
</tr>
<tr>
<td style="width: 10px; text-align: center;">1</td>
<td style="width: 5px; background-color: #000000; text-align: center;"> </td>
<td style="width: 500px; background-color: #000000; text-align: right; height: 40px;"><font face="Arial, Helvetica, sans-serif"><font size="5"><font color="#00FF00"> </font></font></font></td>
<td style="width: 3px; background-color: #000000; text-align: center;"> </td>
<td style="width: 20px; text-align: center; background-color: #000000;"><button type="button" onclick="GetData('1')">OFF</button></td>
</tr>
<tr>
<td style="width: 10px; text-align: center;">2</td>
<td style="width: 5px; background-color: #000000; text-align: center;"> </td>
<td style="width: 500px; background-color: #000000; text-align: right; height: 40px;"><font face="Arial, Helvetica, sans-serif"><font size="5"><font color="#00FF00"> </font></font></font></td>
<td style="width: 3px; background-color: #000000; text-align: center;"> </td>
<td style="width: 20px; text-align: center; background-color: #000000;"><button type="button" onclick="GetData('2')">OFF</button></td>
</tr>
<tr>
<td style="width: 10px; text-align: center;">3</td>
<td style="width: 5px; background-color: #000000; text-align: center;"> </td>
<td style="width: 500px; background-color: #000000; text-align: right; height: 40px;"><font face="Arial, Helvetica, sans-serif"><font size="5"><font color="#00FF00"> </font></font></font></td>
<td style="width: 3px; background-color: #000000; text-align: center;"> </td>
<td style="width: 20px; text-align: center; background-color: #000000;"><button type="button" onclick="GetData('3')">OFF</button></td>
</tr>
<tr>
<td style="width: 10px; text-align: center;">4</td>
<td style="width: 5px; background-color: #000000; text-align: center;"> </td>
<td style="width: 500px; background-color: #000000; text-align: right; height: 40px;"><font face="Arial, Helvetica, sans-serif"><font size="5"><font color="#00FF00"> </font></font></font></td>
<td style="width: 3px; background-color: #000000; text-align: center;"> </td>
<td style="width: 20px; text-align: center; background-color: #000000;"><button type="button" onclick="GetData('4')">OFF</button></td>
</tr>
<tr>
<td style="width: 10px; text-align: center;">5</td>
<td style="width: 5px; background-color: #000000; text-align: center;"> </td>
<td style="width: 500px; background-color: #000000; text-align: right; height: 40px;"><font face="Arial, Helvetica, sans-serif"><font size="5"><font color="#00FF00"> </font></font></font></td>
<td style="width: 3px; background-color: #000000; text-align: center;"> </td>
<td style="width: 20px; text-align: center; background-color: #000000;"><button type="button" onclick="GetData('5')">OFF</button></td>
</tr>
<tr>
<td style="width: 10px; text-align: center;">6</td>
<td style="width: 5px; background-color: #000000; text-align: center;"> </td>
<td style="width: 500px; background-color: #000000; text-align: right; height: 40px;"><font face="Arial, Helvetica, sans-serif"><font size="5"><font color="#00FF00"> </font></font></font></td>
<td style="width: 3px; background-color: #000000; text-align: center;"> </td>
<td style="width: 20px; text-align: center; background-color: #000000;"><button type="button" onclick="GetData('6')">OFF</button></td>
</tr>
<tr>
<td style="width: 10px; text-align: center;">7</td>
<td style="width: 5px; background-color: #000000; text-align: center;"> </td>
<td style="width: 500px; background-color: #000000; text-align: right; height: 40px;"><font face="Arial, Helvetica, sans-serif"><font size="5"><font color="#00FF00"> </font></font></font></td>
<td style="width: 3px; background-color: #000000; text-align: center;"> </td>
<td style="width: 20px; text-align: center; background-color: #000000;"><button type="button" onclick="GetData('7')">OFF</button></td>
</tr>
<tr>
<td style="width: 10px; text-align: center;">8</td>
<td style="width: 5px; background-color: #000000; text-align: center;"> </td>
<td style="width: 500px; background-color: #000000; text-align: right; height: 40px;"><font face="Arial, Helvetica, sans-serif"><font size="5"><font color="#00FF00"> </font></font></font></td>
<td style="width: 3px; background-color: #000000; text-align: center;"> </td>
<td style="width: 20px; text-align: center; background-color: #000000;"><button type="button" onclick="GetData('8')">OFF</button></td>
</tr>
<tr>
<td style="width: 10px; text-align: center;">9</td>
<td style="width: 5px; background-color: #000000; text-align: center;"> </td>
<td style="width: 500px; background-color: #000000; text-align: right; height: 40px;"><font face="Arial, Helvetica, sans-serif"><font size="5"><font color="#00FF00"> </font></font></font></td>
<td style="width: 3px; background-color: #000000; text-align: center;"> </td>
<td style="width: 20px; text-align: center; background-color: #000000;"><button type="button" onclick="GetData('9')">OFF</button></td>
</tr>
</table>
<p align="center"><font size="4"><font face="Arial, Helvetica, sans-serif">НПФ Симплекс 2014</font></font></p>
</body>
</HTML>
-
- Спасибо... но букв все равно много - IBAH(18.06.2019 16:32)