Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
cancatinating new line in javascript
madmax
i am tring to concatinating values with a new line in javascript? but somehow it's not working.
for (n = 0; n <(code.length);n++ )
{
var tText = code + "-----" + name + "\n"; //here i can not concatinating new line so what will be the right code
calloutForm.elements.value = tText;
var ttText = ttText + (calloutForm.elements.value);
}
calloutForm.elements.value = ttText;
any suggestion?
Find more posts tagged with
Comments
Migrateduser
What
is
the output? I'd suggest changing your loop declaration only to declare "n", such that:
for (var n=0; n<code.length; n++)
Other than that, you may need to escape the n two or more times (instead of once, as we're all accustomed to).
Some context would help -- can you attach the PT (presumably) or whatever contains this code?
Dave
Current Environment(s):
(1) TS 6.1 SP2 on W2K3
(2) TS 6.1 SP2 on W2K
madmax
output should be ----
age[0]-----------name[0] //then coz of newline 2nd line will start
age[1]-----------name[1]//again new line
|
|
age[4]----------name[4]//again new line
Migrateduser
That's helpful, but I'd like to know what the output currently
is
. And, again, posting the file that contains this code would help us to help you.
Should the pipe symbols between 1 and 4 be similar to 0, 1, and 4 or should they be literal pipe symbols?
Dave
Current Environment(s):
(1) TS 6.1 SP2 on W2K3
(2) TS 6.1 SP2 on W2K
jbonifaci
Well, knowing nothing about the code around what you wrote, I would re-write your code like this:
var tempText = '';
for (n=0; n<code.length; n++)
{
tempText += code + "-----" + name + "\n";
}
calloutForm.elements.value = tempText;
If that doesn't work, there is something else wrong with your code. FYI, if you are using perl to output this javascript, you will likely have to use \\n instead of just \n.
madmax
hi jbonifaci;
i tried but it's not working. what happened i got all the array value in a single string. like
age[0]------------name[0]age[1]-----------name[1]age[2]-------------name[2]
jbonifaci
I have a silly question for you. Is the field you are trying to set the value to a textarea or a text input box? If it is a text input box, you can not have new lines in it and it will ignore them when you are setting the value.
akshathp
what is your html code for the form in which you have this field?
I want to see how you are using textarea tag.
Thanks!
-Akshat
Akshat Pramod Sharma