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.
Can somebody, more proficient in javascript than me, tell me how I can achieve this.Code: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 != '' ) { telephones=telephones+phoneName; foundPhone = true; optionCntr++ } } selObj.setAttribute("value",telephones); }



Reply With Quote
Bookmarks