Javascript handling textarea

Posted by bbenton on Stack Overflow See other posts from Stack Overflow or by bbenton
Published on 2010-05-31T22:57:13Z Indexed on 2010/05/31 23:03 UTC
Read the original article Hit count: 221

Filed under:
|
|
|
|

Hi all,

I'm a bit new to Javascript and am trying to create a delimited string from a textare. The problem is when passing in the textarea, it adds newlines for each row on the textarea. I need to have the entire textarea parsed into a string with a delimiter for each line (replacing the newline char). So for example, if you passed in a textarea with the following lines (which is also how it looks when using the alert function):

abcd efgh ijkl

It would look like: abcd-efgh-ijkl after parsing.

function submitToForm(form)
{
 var param_textarea  = form.listofplugins.value;
 var test = param_textarea.replace(/\\r?\\n/, /:/)
 alert(test);

}

Thanks a lot!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html