-3
無法使用getElementById(「VAL5」+ i)。 然後輸入3不運行無法使用getElementById
我用這個代碼足夠的信息希望能提供
錯誤是某處線
/* DigitalInput */
指數= input2_offs 爲(i = 0; i < 4; i ++) getElementById(「VAL5」+ i).src = valueArray [input2_offs [i]] ==「0」? 'GIF/dot_red.gif': 'GIF/dot_gr.gif'
哪裏出了問題
enter code here
<!--
var req = null;
req = AjaxInit();
var PostBuffer = new Array;
var Trace;
/* number of channels per sensor input type */
var InputChannels = 4; /* max 4 digital inputs */
var names = new Array();
var units = new Array();
var offs = new Array();
var gain = new Array();
var value = new Array();
var input2_offs = 25;
var input3_offs = 26;
/*
this function is called on body load and later every 5s
request a new set of data from the controller
*/
function UpDate()
{
var x = Math.random()*1000; /* add random number to the url to avoid caching the content in the browser */
x=x.toFixed(3);
AjaxGetRequest("/GetState.csv"+"?a="+x,UpdateTraceBuffers);
return false;
}
/*
call back routine when the controller has send the data
this function separates all items in separate arrays as :
names, units, offsets , gains and the raw values
*/
function UpdateTraceBuffers()
{
Trace = req.responseText.split('\n');
names = Trace[TraceNameOffs].split(',');
units = Trace[TraceUnitOffs].split(',');
offs = Trace[TraceOffs].split(',');
gain = Trace[TraceGain].split(',');
value = Trace[TraceDataoffs].split(',');
UpdateWebSite(); /* user routine , update all items */
if(timerHandle == 0)
{
timerHandle = window.setInterval("UpDate()", 5000);
}
}
/* DigitalInput */
index = input2_offs;
for(i=0;i<4;i++)
getElementById("VAL5"+i).src = valueArray[input2_offs[i]] == "0" ? 'gif/dot_red.gif' : 'gif/dot_gr.gif';
index = input3_offs;
v = (parseFloat(offs[index]) + parseFloat(gain[index])* parseFloat(value[index])).toFixed(0);
getElementById("SENS_VAL6").innerHTML = v;
//-->
<td class="mytd"><div align="center"><img src="gif/dot_red.gif"
width="24" height="24" id="VAL5"></div></td>
<td id="SENS_VAL6" class="mytd" align="right"> </td>
它是'document.getElementById',不只是'getElementBId' – entropic 2014-09-10 20:20:43
您可能需要重新格式化這個...您的getElementById函數不在腳本塊內。 – aggietech 2014-09-10 20:21:45