title: Array Question related to both HTML and Javascript
body: <p>I have this simple bit of code. When the user chooses Others, an <code>&lt;input type=text&gt;</code> should appear.</p>
  
  <p>But it only works when there is only one value selected. </p>
  
  <p>Users can randomly add in the same <code>select</code> type, so the code can't be changed. For what I know, in javascript need to use <code>foreach</code>.</p>
  
  <p>So my question is, how to let each of the <code>&lt;input type=text&gt;</code> appear in EACH of the <code>select</code> elements instead of it only appearing in the first one.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function Pack(val){
   var element=document.getElementById('otherpack');  
   if(val=='others')
     element.style.display='block';
   else  
     element.style.display='none';
  } </code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;select name="Type[]" onchange='Pack(this.value);' required&gt;
  &lt;option value="Orange"&gt;Orange&lt;/option&gt; 
  &lt;option value="Apple"&gt;Apple&lt;/option&gt;    
  &lt;option value="others"&gt;Others&lt;/option&gt;                          
  &lt;input type="text" name="othermethod[]" id="otherpack" style="display:none"/&gt;
  &lt;/select&gt;
  
  &lt;select name="Type[]" onchange='Pack(this.value);' required&gt;
  &lt;option value="Orange"&gt;Orange&lt;/option&gt; 
  &lt;option value="Apple"&gt;Apple&lt;/option&gt;    
  &lt;option value="others"&gt;Others&lt;/option&gt;                          
  &lt;input type="text" name="othermethod[]" id="otherpack" style="display:none"/&gt;
  &lt;/select&gt;
  
  &lt;select name="Type[]" onchange='Pack(this.value);' required&gt;
  &lt;option value="Orange"&gt;Orange&lt;/option&gt; 
  &lt;option value="Apple"&gt;Apple&lt;/option&gt;    
  &lt;option value="others"&gt;Others&lt;/option&gt;                          
  &lt;input type="text" name="othermethod[]" id="otherpack" style="display:none"/&gt;
  &lt;/select&gt;</code></pre>
  </div>
  </div>
  </p>