2014-09-10 100 views
-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">&nbsp;</td> 
+0

它是'document.getElementById',不只是'getElementBId' – entropic 2014-09-10 20:20:43

+0

您可能需要重新格式化这个...您的getElementById函数不在脚本块内。 – aggietech 2014-09-10 20:21:45

回答

相关问题