Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerate Select instead of Input
    text
    copied!<p><strong>Due to restrictions of editing some of my templates I really need your help with:</strong></p> <ol> <li>generate a select list with predefined options instead of input field</li> <li>input field to be hidden after select is generated</li> <li>when some option selected transfer that option's value into that hidden input</li> </ol> <hr> <p><strong>I provide some HTML to be more clear:</strong></p> <p><em>This is what we've got in the template before jQuery is applied:</em></p> <pre><code>&lt;input type="text" id="myId" name="myName" value=""&gt; </code></pre> <p><em>This is what we need it to be after jQuery is applied</em></p> <pre><code>&lt;select id="mySelect"&gt; &lt;option&gt;a&lt;/option&gt; &lt;option&gt;b&lt;/option&gt; &lt;option&gt;c&lt;/option&gt; &lt;/select&gt; &lt;input type="text" id="myId" name="myName" value="" style="display:none"&gt; </code></pre> <p><strong>Please note:</strong> I need to predefine options value and their quantity. Select must be generated right where input field was.</p> <p><strong>Also</strong>: I also really need to generate two or more select lists in some templates and transfer selected option's values consistently into one input.</p> <p>Example:</p> <pre><code> &lt;select id="mySelect1"&gt; &lt;option&gt;a&lt;/option&gt; &lt;/select&gt; &lt;select id="mySelect2"&gt; &lt;option&gt;b&lt;/option&gt; &lt;/select&gt; &lt;input type="text" id="myId" name="myName" value="a b" style="display:none"&gt; //a + b added </code></pre> <p><em>Thanks in advance!</em></p>
 

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