title: Display List Items in a label using Javascript
body: <p>Hey guys I have been stuck on this issue for a couple of days. I have two list boxes that a user can transfer data back and forth between. I need the items that are in the listbox on the right to also display in a label located in a table below the listboxes.</p>
  
  <p>I have gotten the text to display in the label but I can not get it to enter a new line for each item (like they would display in the listbox). The text is coming up with spaces and still doesn't split on a new line. I am fairly new to javascript so please be kind :) </p>
  
  <p>Here is my javascript:</p>
  
  <pre><code>    function displayLabel()
              {
                  var item = document.getElementById("lstRightBox").options.innerText;
                  var arr = new Array();
                  var test = item.split(arr.join("|"));
                  document.getElementById("label").innerHTML = test.join("\r\n");
                  return true;
              }
  </code></pre>
  
  <p><strong>ADDED</strong></p>
  
  <p>Here is the code that transfers the items inbetween the listboxes:</p>
  
  <pre><code>    // This moves selected items
      function move_list_items(lstLeftBox, lstRightBox)
        {
          $("#"+lstLeftBox+"  option:selected").appendTo("#"+lstRightBox).toString;
        }
  
        //this will move all items 
      function move_list_items_all(lstLeftBox, lstRightBox)
        {
          $("#"+lstLeftBox+" option").appendTo("#"+lstRightBox);
        }  
  </code></pre>
  
  <p><strong>EDIT</strong>  </p>
  
  <p>Here is an update to my display function. I am calling it in my move functions (listed above) so that it is executed each time a button is clicked. I am currently getting [object Object] displaying in my label for each item moved.</p>
  
  <pre><code>    function displayLabel(lstLeftBox, lstRightBox)
            {
              $("#"+lstRightBox+"  option").each(function(){
                  document.getElementById("label").innerHTML += $(this);
              });
            } 
  </code></pre>