Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
340 views
in Technique[技术] by (71.8m points)

concatenation - How to force a line break on a Javascript concatenated string?

I'm sending variables to a text box as a concatenated string so I can include multiple variables in on getElementById call.

I need to specify a line break so the address is formatted properly.

document.getElementById("address_box").value = 
(title + address + address2 + address3 + address4);

I've already tried after the line break and after the variable. and tried changing the concatenation operator to +=.

Fixed: This problem was resolved using;

document.getElementById("address_box").value = 
(title + "
" + address + "
" + address2 + "
" +  address3 +  "
" + address4);

and changing the textbox from 'input type' to 'textarea'

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can't have multiple lines in a text box, you need a textarea. Then it works with between the values.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...