title: How to initialize a parameter in javascript? document.getElementById("DataAreaXa")
body: <p>When running my script I get "<strong>Unable to get value of the property 'innerHTML': object is null or undefined</strong>".</p>
  
  <p>From what I found on this forum I need to initialize a parameter.</p>
  
  <p>I have several buttons in my app <code>&lt;input id=runbutton  type="button" value="&amp;#8594;" onClick="runScriptUp(DataArea1a,DataArea1b,arr1)"&gt;</code> until <code>DataArea7a,DataArea7b,arr7</code>.</p>
  
  <p>OnClick function is triggered and parameters passed: </p>
  
  <pre><code>function runScriptUp(DataAreaXa,DataAreaXb,arrX){
  document.getElementById("DataAreaXa").innerHTML = arrX[2];
  document.getElementById("DataAreaXb").innerHTML = arrX[1]*arrX[2];
  }
  </code></pre>
  
  <p>Function fetches data from 7 arrays I have <code>var arr1 = ["Incidents",    Sinc,           0,              0];</code>, again until <code>arr7</code> (arrX[1] has values assigned in <code>var</code>s.)</p>
  
  <p>and it should place <code>DataAreaXa</code> and <code>DataAreaXb</code> values into corresponding <code>span</code>s showing values after <code>onclick</code> is executed <code>&lt;span id=DataArea1a name=a&gt;</code> and <code>&lt;span id=DataArea1 name=a&gt;</code> again until <code>DataArea7a</code> and <code>DataArea7b</code>.</p>
  
  <p>Unfortunately I get "Unable to get value of the property 'innerHTML': object is null or undefined".</p>
  
  <p>I tried to initialize <code>DataAreaXa</code> and <code>DataAreaXb</code> in <code>onload</code> section but writing it 14 times is pointless.
  I tried with <code>for</code> as well but I guess I'm not doing it right.</p>
  
  <pre><code>for (X=1; X&lt;7;X++){
  document.getElementById("DataAreaXa")
  document.getElementById("DataAreaXb")
  }
  </code></pre>
  
  <p>or even</p>
  
  <pre><code>for (X=1; X&lt;7;X++){
  document.getElementById("DataArea"+X+"a")
  document.getElementById("DataArea"+X+"b")
  }
  </code></pre>
  
  <p>Can I even use a function to run it 7 times for both <code>Xa</code> and <code>Xb</code> instead of writing it 14 times?</p>
  
  <p>Thanks. m</p>