selected index in dropdown list throwing error when no value is selected
<p>I am trying to access the values selected from a dropdown list and populate in a row of a table . I am using:</p>

<pre><code>cell2.innerHTML = choiceInput.options[choiceInput.selectedIndex].text; 
</code></pre>

<p>where <code>choiceInput</code> is the name of my dropdown element. </p>

<p>This works if I select an option from the dropdown, but if I do not select anything from the dropdown, I get a <code>null</code> value selected and get a JavaScript error. </p>

<p>Can someone help me with this?</p>
