Javascript (no libraries) split text to populate textboxes with different text
<p>Related to <a href="http://stackoverflow.com/questions/16289107/split-urls-text-by-spaces-into-2-boxes-javascript-only-no-libraries">Split urls/text by spaces into 2 boxes Javascript Only no libraries</a></p>

<p>What I want to do is split text, which is already in the textbox. I want it to be put into a variable. Then, because there are 2 boxes, I want the first one filled with 1 2 3 4 5. The second box filled with 6 7 8 9 10. Or the first box with 1 3 5 7 9 and the second one with 2 4 6 8 10. Whichever way works best/easiest.</p>

<p>This is what I have tried so far.</p>

<p>Code:</p>

<pre><code>&lt;HTML&gt;
  &lt;HEAD&gt;
    &lt;SCRIPT LANGUAGE="JavaScript"&gt;
      var split_text;
      var urls_1;
      var numbercount=0;
      var totals;
      var half_totals;
      function addto_boxes(form) {
        split_text = document.getElementById("text_to_split").value;
        urls_1 = split_text.split(" ", 100000);
        totals = urls_1.lenght - 1;
        half_totals = (totals / 2 );
        while (numbercount &lt;= half_totals ){
          if (numbercount &gt;= half_totals ){
            numbercount = 0;
            break;
          document.getElementById("input_box1").value = document.getElementById("input_box1").value + urls_1[numbercount] + " ";
          document.getElementById("input_box2").value = document.getElementById("input_box2").value + urls_1[numbercount + half_totals] + " ";
          numbercount++
        }
      }
    &lt;/SCRIPT&gt;
  &lt;/HEAD&gt;
  &lt;BODY&gt;
    &lt;input id="Split" type="button" value="Add to boxes" onclick="addto_boxes(this.form);"/&gt;
    &lt;BR&gt;
    &lt;textarea NAME="texttosplit" id="text_to_split" VALUE="" rows="4" cols="75"&gt;1 2 3 4 5 6 7 8 9 10 &lt;/textarea&gt;
    &lt;BR&gt;
    &lt;FORM NAME="myform" ACTION="" METHOD="GET"&gt;Put 1st urls in this box (Separated by a space):
      &lt;textarea NAME="inputbox" id="input_box1" VALUE=""rows="4" cols="75"&gt;&lt;/textarea&gt;
      &lt;BR&gt;
      Put 2nd urls in this box &lt;BR&gt;
      &lt;textarea NAME="inputbox2" id="input_box2" VALUE=""rows="4" cols="75"&gt;&lt;/textarea&gt;
      &lt;BR&gt;
      &lt;INPUT TYPE="reset"&gt;
    &lt;/FORM&gt;
  &lt;/BODY&gt;
&lt;/HTML&gt;
</code></pre>
