title: Javascript: How to call <li> element value
body: <p>can anyone give me the javascipt code to extract following instances of <code>sf_number</code> from my HTML?</p>
  
  <pre><code>&lt;ul class="multi_value_field" style="width: 99.5%;"&gt;
  &lt;li class="choice" choice_id="sf_number"&gt;sf_number&lt;a class="close"&gt;×&lt;/a&gt;&lt;input type="hidden" name="ticket[set_tags][]" value="sf_number" style="display: none;"&gt;&lt;/li&gt;
  &lt;li class="search_field_item"&gt;&lt;input type="text" autocomplete="off" tabindex="20"&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Basically I want to replace all three instances of <code>sf_number</code> with a different
  value from another field. This is the code I have made to try and extract sf_number but doesn't work so far:</p>
  
  <pre><code>var n2 = document.getElementsByClassName("multi_value_field").getElementsByClassName("choice");
  </code></pre>
  
  <p>Thanks in advance</p>
  
  <p><strong>UPDATE</strong>
  How can I change my existing code by using your suggestions below?</p>
  
  <pre><code>&lt;html&gt;
  &lt;script type="text/javascript"&gt;
  copy = function()
  {
      var n1 = document.getElementById("ticket_fields_20323656");
      var n2 = document.getElementById("choice").getElementsByClassName("sf_number")[0] ;
      n2.value = n1.value;
  }
  &lt;/script&gt;
  
  &lt;input type="button" value="copy" onClick="copy();" /&gt;
  &lt;/html&gt;​​​​​
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>This doesn't seem to work, is it correct?</p>
  
  <pre><code>&lt;html&gt;
  &lt;script type="text/javascript"&gt;
  copy = function()
  {
  var fields = document.getElementsByClassName("multi_value_field")[0].getElementsByClassName("choice");
  
  for (var i = 0; i &lt; fields.length; i++)
  
      fields[i].setAttribute("choice_id", "document.getElementById("ticket_fields_20323656").value");
      fields[i].getElementsByTagName("input")[0].value = "document.getElementById("ticket_fields_20323656").value";
      fields[i].firstChild.nodeValue = "document.getElementById("ticket_fields_20323656").value";
  }
  &lt;/script&gt;
  
  &lt;input type="button" value="copy" onClick="copy();" /&gt;
  &lt;/html&gt;​​​​​
  </code></pre>