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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.