Results 1 to 1 of 1

Thread: Displaying items as individual lines in a textarea using js

  1. #1
    Join Date
    Apr 2009
    Cognac, France
    Thanked 57 Times in 57 Posts

    Default Displaying items as individual lines in a textarea using js

    I am trying to use the contents of array to populate a <textarea>, or to appear in a 'box'.

    The selection from the array is defined by a SELECT box.

    I can get everything working with the exception of the line 'formatting' for the 'textarea'.

    To enable me to test it I am creating a variable called telephones from all the relevant elements and this is displaying in the 'textarea'.

    However, I want each element of the array to be shown as a separate line in the 'textarea'.

    This is my code that gets the appropriate individual elements from the array.

    function populatePhone() {
      var selObj = document.getElementById('phoneSelect');
      var telephones="";
      var foundPhone = false;
    	var phoneLineArray = phone.split("|");  // Split into lines
      var optionCntr = 1;
      for (var loop = 0; loop < phoneLineArray.length; loop++) {
        lineArray = phoneLineArray[loop].split(":");
        stateCode  = TrimString(lineArray[0]);
        phoneCode    = TrimString(lineArray[1]);
        phoneName    = TrimString(lineArray[2]);
      if (document.getElementById('stateSelect').value == stateCode && stateCode != '' ) {
          foundPhone = true;
    Can somebody, more proficient in javascript than me, tell me how I can achieve this.
    Last edited by forum_amnesiac; 05-23-2009 at 09:00 AM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts