troubleshooting Question

Javascript to Insert a break line in TextArea boxes

Avatar of TheUndecider
TheUndeciderFlag for United States of America asked on
JavaScriptE-Commerce
5 Comments2 Solutions769 ViewsLast Modified:
Hello,

I'm working on a web page and I have these read only text areas where the user enters several options for the products they want.   When they enter these options I am able to create text boxes for each input, but when they go to the next page, all entered text becomes read only and it's displayed in one single textarea.  All fields are separated by a comma.

Is there a way that I can create a javascript code that looks for any textarea in the page, look for their content and enters a break <br> before a comma so the text looks easier to read?  These breaks are only for visual purposes, I don't want to edit the field values. I just want them to look better than one single line.

Here's 2 textareas where you can see what I'm talking about.  

<textarea readOnly class="cart" wrap="physical" name="0:freeopt" rows="4" cols="40" ID="Textarea1">Product,Widget,Type,Bucket,Color,Blue</textarea>

<textarea readOnly class="cart" wrap="physical" name="1:freeopt" rows="4" cols="40" ID="Textarea2">Product,Shell,Type,Wood,Color,Red</textarea>

I need them to look like this:

Product,
Widget,
Type,
Bucket,
Color,
Blue

Any ideas?

Thanks!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros