String from array not working when passed to JS
<p>The following works well:</p>

<pre><code>var options = '&lt;select&gt;&lt;option value ="Unknown"&gt;Unknown&lt;/option&gt;&lt;option value ="Yes"&gt;Yes&lt;/option&gt;&lt;option value ="No"&gt;No&lt;/option&gt;&lt;option value ="Both"&gt;Both&lt;/option&gt;&lt;/select&gt;';
alert(options)
</code></pre>

<p>However, if that string is produced via a PHP foreach, the variable options is not recognized, hence I cannot use with JS. For example:</p>

<pre><code>&lt;?php foreach($pickListFields as $field_id =&gt; $options): ?&gt;
    &lt;?php 
        $options_array = explode("\n", $options); 
        $options_select = '&lt;select&gt;';
        foreach($options_array as $k =&gt; $option) {
            $options_select .= '&lt;option value ="' . $option . '"&gt;' . $option . '&lt;/option&gt;';
        }
        $options_select .= '&lt;/select&gt;';
    ?&gt;
    var options = '&lt;?= $options_select ?&gt;';
&lt;?php endforeach; ?&gt;
</code></pre>

<p>The above variable options produced, does not work, even though when I see the source code with Firefox I can see that var options is:</p>

<pre><code>var options = '&lt;select&gt;&lt;option value ="Unknown"&gt;Unknown&lt;/option&gt;&lt;option value ="Yes"&gt;Yes&lt;/option&gt;&lt;option value ="No"&gt;No&lt;/option&gt;&lt;option value ="Both"&gt;Both&lt;/option&gt;&lt;/select&gt;';
</code></pre>

<p>Why then it cannot be used, if it is the same as the first example? I cannot alert that, or assign it to a field, but I can with the first example. </p>
