title: JavaScript HTML object HTMLSelectElement
body: <p>I am trying to create a little HTML form where my users need to select some options from checkboxes and dropdown lists.  The intended outcome is a text that is generated dynamically as the users change their choices.
  The idea does work but I keep getting “[object HTMLSelectElement]” instead of the value of the selected choice from the dropdown box.  If one of you veteran JavaScript programmers could give me your opinion I’d greatly appreciate it!  I spent quite some time double checking everything and I’m pretty sure my code is correct syntactically but I could be completely wrong without realizing it.  I’m new at JavaScript so I’m still in a learning phase.</p>
  
  <p>HTML Code:</p>
  
  <pre><code>&lt;form name="input" action="" method="get"&gt;
  &lt;input type="checkbox" name="stCode" id="ai1" onChange="generateSTcode()"&gt;
  Analog Input B1
  &lt;select name="sensorType" id="sensorType1" onChange="generateSTcode()"&gt;
  &lt;option value="2"&gt;0-1 Vdc&lt;/option&gt;
  &lt;option value="3"&gt;0-10 Vdc&lt;/option&gt;
  &lt;option value="4"&gt;4-20mA&lt;/option&gt;
  &lt;option value="5"&gt;Off/On&lt;/option&gt;
  &lt;option value="6"&gt;0-5 Vdc&lt;/option&gt;
  &lt;/select&gt;
  &lt;select name="sensor" id="sensor1" onChange="generateSTcode()"&gt;
  &lt;option value="oatp_ai"&gt;Outside air temperature&lt;/option&gt;
  &lt;option value="satp_ai"&gt;Supply air temperature&lt;/option&gt;
  &lt;option value="ratp_ai"&gt;Return air temperature&lt;/option&gt;
  &lt;option value="mxtp_ai"&gt;Mixed air temperature&lt;/option&gt;
  &lt;/select&gt;&lt;br&gt;&lt;br&gt;
  &lt;input type="checkbox" name="stCode" id="ai2" onChange="generateSTcode()"&gt;
  Analog Input B2
  &lt;select name="sensorType" id="sensorType2" onChange="generateSTcode()"&gt;
  &lt;option value="2"&gt;0-1 Vdc&lt;/option&gt;
  &lt;option value="3"&gt;0-10 Vdc&lt;/option&gt;
  &lt;option value="4"&gt;4-20mA&lt;/option&gt;
  &lt;option value="5"&gt;Off/On&lt;/option&gt;
  &lt;option value="6"&gt;0-5 Vdc&lt;/option&gt;
  &lt;/select&gt;
  &lt;select name="sensor" id="sensor2" onChange="generateSTcode()"&gt;
  &lt;option value="oatp_ai"&gt;Outside air temperature&lt;/option&gt;
  &lt;option value="satp_ai"&gt;Supply air temperature&lt;/option&gt;
  &lt;option value="ratp_ai"&gt;Return air temperature&lt;/option&gt;
  &lt;option value="mxtp_ai"&gt;Mixed air temperature&lt;/option&gt;
  &lt;/select&gt;&lt;br&gt;&lt;br&gt;
  &lt;input type="checkbox" name="stCode" id="ai3" onChange="generateSTcode()"&gt;
  Analog Input B3
  &lt;select name="sensorType" id="sensorType3" onChange="generateSTcode()"&gt;
  &lt;option value="2"&gt;0-1 Vdc&lt;/option&gt;
  &lt;option value="3"&gt;0-10 Vdc&lt;/option&gt;
  &lt;option value="4"&gt;4-20mA&lt;/option&gt;
  &lt;option value="5"&gt;Off/On&lt;/option&gt;
  &lt;option value="6"&gt;0-5 Vdc&lt;/option&gt;
  &lt;/select&gt;
  &lt;select name="sensor" id="sensor3" onChange="generateSTcode()"&gt;
  &lt;option value="oatp_ai"&gt;Outside air temperature&lt;/option&gt;
  &lt;option value="satp_ai"&gt;Supply air temperature&lt;/option&gt;
  &lt;option value="ratp_ai"&gt;Return air temperature&lt;/option&gt;
  &lt;option value="mxtp_ai"&gt;Mixed air temperature&lt;/option&gt;
  &lt;/select&gt;&lt;br&gt;&lt;br&gt;
  &lt;/form&gt; 
  &lt;div id="generatedCode" class="generatedCode"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>JavaScript Code:</p>
  
  <pre><code>function generateSTcode(){
  var stCodegenerated = "";    
  var analogInputCh = new Array(3);
  analogInputCh[0] = document.getElementById('ai1');
  analogInputCh[1] = document.getElementById('ai2');
  analogInputCh[2] = document.getElementById('ai3');
  var sensorType = new Array(3);
  sensorType[0] = document.getElementById('sensorType1');
  sensorType[1] = document.getElementById('sensorType2');
  sensorType[2] = document.getElementById('sensorType3');
  var sensor = new Array(3);
  sensor[0] = document.getElementById('sensor1');
  sensor[1] = document.getElementById('sensor2');
  sensor[2] = document.getElementById('sensor3');
  for(i = 0; i &lt; analogInputCh.length; i++){
  if(analogInputCh[i].checked){
  var iTemp = i + 1;
  stCodegenerated += "Ain_Conf(" + iTemp + ", " + sensorType[i] + ", AI_0" + iTemp + "); " 
  + sensor[i] + " := AI_0" + iTemp + ";" + "&lt;br&gt;&lt;br&gt;";
  }
  }
  document.getElementById("generatedCode").innerHTML = stCodegenerated;
  }
  </code></pre>
  
  <p>DEMO: <a href="http://jsfiddle.net/XB63m/" rel="nofollow">http://jsfiddle.net/XB63m/</a></p>