How do I get values from a text area with JS?

I need to get values from a text area to pass in a querystring, but how do I get multiple values using Javascript?

I’m sure it’s a simple thing, but I couldn’t find how in the forum or in any JS guide online.

Bob

Subject: How do I get values from a text area with JS?

Dear Bob

Craete one more field(name as test1) in the form and make it hidden field

and write @implode(textarea;“#”) in the default value of test field

now in you javascript code write

str=document.getElementById(test).value

strarray=str.split(“#”)

for( i=0;i<strarray.length;i++)

{

alert(strarray[i])

}

may be it is somewhat complex but you can use it inorder to get multiple values

Subject: That won’t work for me…

Thanks for that suggestion, but unfortunately, the document has not yet been saved, the user has simply entered some values in a text area and now I need JS to get those values. So, another computed field won’t work for me. Do you know how I can get the values directly from the field?

Subject: RE: That won’t work for me…

Textareas don’t have the concept of multiple values. It’s just text, that might - amongst other things - contain line brakes. While Domino renders multi value fields as textareas, if you set their properties accordingly, and stores the content as multiple values when submitting the form, this strictly happens inside Domino. JavaScript knows nothing about that.

So the first question would be: What should be your delimiter for what you plan to treat as multiple values?

Subject: I can use a comma

… because the field contains a list of part numbers.

Subject: var t= document.forms[‘form’].elements[‘textarea’].value;

Subject: That works great!, but what about the multiple values?

My goal is to pass the value in a url, so an entry of

123

456

789

needs to be a single string like 123~456~789. How do I transform the multi-value result into a string value?

Subject: Well it’s not really multiple values yet.

It’s still a single value, with \n as newline separators.

So you want to replace \n with ~

You could use a regular expression

t = t.replace(/[\n\r]+/g, “~”);

Subject: SOLUTION

Thanks for your help, Carl!

Here was my problem… I have a text area on my form where the user is to type multiple item numbers. I need to get those numbers, string them together and send them in a url back to the server so I can use them to get info from their ERP system. I had everything else in place, but couldn’t figure out how to get the item numbers in a string format.

This is how I’ve done it.

var t=frm.elements[‘ItemNums’].value;

nt = t.replace(“\n”, “~”);

nt2 = nt.replace(“\r”, “”);

where \n is a newline character and \r is a carriage return character. So, now for an entry of

123

456

I get 123~456.

Hope this helps someone else!

Subject: That will only work for two values

Replace is not Replaceall which is why I used a regular expression.