Note that there are some explanatory texts on larger screens.

plurals
  1. POdynamic options to select dropdown
    text
    copied!<pre><code>function loop_dropdown($valor) { for ($i = 0; $i &lt; count($valor); $i++) { echo "&lt;option value='$valor[$i][0]' class='dr'&gt;".$valor[$i][1].'&lt;/option&gt;'; } } &lt;form method="post" id="customForm2" action=""&gt; &lt;?php for ($i = 0; $i &lt; count($languages); $i++) { $u = $i+1; echo ' &lt;div class = "linguas" id="input_'.$u.'" style="margin-bottom: 10px;"&gt; &lt;select name="myformdata[linguas][]"&gt; &lt;option value="0" class="dr"&gt;Lingua&lt;/option&gt; '.loop_dropdown($languages_dropdown).' &lt;/select&gt; &lt;/div&gt;'; } ?&gt; &lt;/form&gt; </code></pre> <p><strong>var_dump($languages_dropdown);</strong></p> <pre><code> array 0 =&gt; array 0 =&gt; int 2 1 =&gt; string 'Espanhol' (length=8) 1 =&gt; array 0 =&gt; int 1 1 =&gt; string 'Português' (length=10) </code></pre> <p>Two problems:</p> <p>First, i get these options. Why <code>value="Array[0]"</code> and not <code>value="1"</code> and <code>value="2"</code> ?</p> <pre><code>&lt;option class="dr" value="Array[0]"&gt;Espanhol&lt;/option&gt; &lt;option class="dr" value="Array[0]"&gt;Português&lt;/option&gt; </code></pre> <p>Second problem, these two options are not appended to dropdown (select).</p> <p>Any idea ?</p> <p><strong>EDIT (output html):</strong></p> <pre><code>&lt;form id="customForm2" action="" method="post"&gt; &lt;option class="dr" value="2"&gt;Espanhol&lt;/option&gt; &lt;option class="dr" value="1"&gt;Português&lt;/option&gt; &lt;div id="input_1" class="linguas" style="margin-bottom: 10px;"&gt; &lt;select name="myformdata[linguas][]"&gt; &lt;option class="dr" value="0"&gt;Lingua&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/form&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload