Jump to content

Outputting line breaks as line breaks


gerkintrigg

Recommended Posts

I'm trying to make a javascript calculator to work out if something is viable, but there's an issue with the formatting.

I want to output a line break like I can with PHP, but Javascript doesn't want me to do it.

I've tried

\n

and

<br\/>

but neither work.

 

Please help.

 

Here's my code:

<script>
            function ViabilityCheck(){
			// define the variables:
			var print_quote = document.getElementById('print_quote').value;
			var handling = document.getElementById('handling').value;
			var postage = document.getElementById('postage').value;
			var discount = document.getElementById('discount').value;
			var rrp = document.getElementById('rrp').value;
			var output_div_field = document.getElementById('output_div_field').value;

			// now work out the viabilty and put that out as a variable:
			var OurCut = ((rrp/100)*(100-discount));

			var output_div = document.getElementById('output_div');
			while( output_div.firstChild ) {
				output_div.removeChild( output_div.firstChild );
			}

			var OVOurCut='Turnover Per Book: ?'+OurCut.toFixed(2);
			var OVGrossProfit='Turnover less the printing cost Per Book: ?'+(OurCut.toFixed(2)-print_quote);

			output_div.appendChild( document.createTextNode(OVOurCut+'<br\/>'+OVGrossProfit));

		}
            </script>

Link to comment
https://forums.phpfreaks.com/topic/267302-outputting-line-breaks-as-line-breaks/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.