I'm relatively new to HTML, js, coming from Delphi. I have reviewed the following answers but they don't seem to work for me, or I am not understanding what they are saying:
Multi line print
.innerHTML <br> breaking
html <br> and innerHTML problem
Problem: all my text is printing in one line, rather than line breaking.
Below is the HTML source.
<!DOCTYPE HTML>
<html>
<head>
<title>Test Module</title>
</head>
<body >
<p id="demo"></p>
<button id="btnRPCTest" onclick="RPCTest()">Test RPC call</button>
<p id="RPCTarget">(RPC output here...)</p>
<script id="broker" src="scripts/rpcbroker.js" type="text/javascript"></script>
<script>
function RPCTest() {
var Div = document.getElementById("RPCTarget")
Broker_CallV("XUS INTRO MSG", []);
var text = Broker_ResultsDelim("<br />\n");
Div.innerHTML = text;
}
</script>
</body>
</html>
Above, the code makes a remote procedure call (RPC) to the server, and the results are put into a custom TStringList object that I created, that at it's core is an array of strings.
Below, is the code that gets back the results as a string, deliminated by the specified parameter ADelim.
function Broker_ResultsDelim(ADelim) {
return TStringList.GetTextDelim(RPCBrokerV.Results, ADelim);
}
Below, the array of strings should be concatenated into one long string, with contained line breaks.
GetTextDelim: function (Self, ADelim) {
return (Self.FData).join(ADelim) + ADelim;
},
When I run this code, and step through it with the Chrome developer console, I can type 'text' in the console, and the line breaks are correct.
> text
"
...............................................................
.................#.............................................
...###############.......##############..........########......
.################......################........####...####.....
.##.....####..........##....####.....###......##.......####....
.###....###...##............###......##......##................
..##....#######.............###.....###.....###................
.......###..##.............##########.......###....#########...
.......###.................###...............##........###.....
.......###.................###...............###......####.....
......###.................###.................####....###......
...###########........############.............##########......
......................................................###......
................................................########.......
...............................................................
<br />
"
But after the text gets inserted into the div, it is all on one line. I can't demonstrate that here, because when I copy the text (which appears on the screen to be all one line), and paste it into this question on StackOverflow, suddenly is is formatted correctly, with line breaks.
This makes me think that the text does contain the line break BR codes , but they are being ignored in the div.
I would think that this should be an easy question for someone knowledgeable in HTML, but it's got me scratching my head in confusion. Thanks in advance for the help.
Kevin