954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

problem with <br> tag inside <textarea> tag???

I have written some code for template generator but I am having issue getting the formatting when it is generated in the .

I want to have it to look like

Service Affected: {then populated text}
Service Status: {again populated text}
Current/Next Actions: {populated text}

it ends up printing out the

Service Impacted: data
Service Status : lost comms

here is the code I have written.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

  <script language="JavaScript">


  function generate()

  {

      var sms = ''



     var impact = document.sms.impacted.value;

     var status = document.sms.status.value;

     var action = document.sms.action.value;
     var BR = ''
     

	  sms = sms + '<textarea name="template" rows="10" cols="55">';

     sms = sms + 'Service Impacted: '+ impact + '';

     sms = sms + 'Service Status  : '+ status + '';

     sms = sms + 'Next Action     : '+ action +'';

	  sms = sms + '</textarea>';


     document.getElementById('sms').innerHTML=sms;

     //document.getElementById('blank').innerHTML='';

  }

  </script>

<link href="scripts/imt.css" rel="stylesheet" type="text/css" />

</head>

<body>

<script type="text/javascript">

<!--



-->

</script>



<div id="page">

    <div id="wrapper">

        <div id="header"></div>

        <div id="topSpacer"></div>

        <div id="body">&nbsp;

        	<h2 align="center">The Fault logging assistant</h2>

        	<h3 align="center"></h3>

<form name="sms" action="">

 <table name="table" width="500" border="0" align="center">

  <tr align="center">

   <td colspan="2">

    <h3>SMS Template Genterator</h3>

   </td>

  </tr>

  <tr>

   <td><strong>Service Impacted: </strong></td>

   <td>

    <input type="text" name="impacted" value="">

   </td>

  </tr>

  <tr>

   <td><strong>Service Status: </strong></td>

   <td>

    <input type="text" name="status" value="">

   </td>

  </tr>

  <tr>

   <td><strong>Next Action: </strong></td>

   <td>

    <input type="text" name="action" value="">

   </td>

  </tr> 
   <td><input type="button" name="button" value="Generate" onClick="generate()">

  <tr>

  </tr>

  <tr>

   <td colspan="2">    

    <span id='sms'></span>

   </td>

  </tr>

 </table>

<span id="blank"></span>

</form>


        </div>

        <div id="bottomSpacer"></div>

        <div id="footer">

        

        </div>      

    </div>

</div>

</body>

</html>
leviathan185
Junior Poster
105 posts since May 2009
Reputation Points: 19
Solved Threads: 15
 

Have you tried escape characters? \n ?

AshtonHogan
Posting Whiz in Training
210 posts since Jul 2009
Reputation Points: 7
Solved Threads: 1
 

inside quotes of use + /n

I tried it in quotes and it just printed .n in there as well. i tried with out quotes and the code did not execute

leviathan185
Junior Poster
105 posts since May 2009
Reputation Points: 19
Solved Threads: 15
 

Hi,

try to re-apply few changes over lines':

<script type="text/javascript">
// <![CDATA[

  function generate()
  {
      var sms = ''

     var impact = document.sms.impacted.value;
     var status = document.sms.status.value;
     var action = document.sms.action.value;
     var BR = '\n';
     
     sms = sms + '<textarea name="template" rows="10" cols="55">';
     sms = sms + 'Service Impacted: '+ impact + BR;
     sms = sms + 'Service Status  : '+ status + BR;
     sms = sms + 'Next Action     : '+ action + BR;
     sms = sms + '</textarea>';

     document.getElementById('sms').innerHTML=sms;
     //document.getElementById('blank').innerHTML='';
  }
// ]]>
</script>


hope it helps...

essential
Posting Shark
974 posts since Aug 2008
Reputation Points: 114
Solved Threads: 138
 

Hi,

try to re-apply few changes over lines':

<script type="text/javascript">
// <![CDATA[

  function generate()
  {
      var sms = ''

     var impact = document.sms.impacted.value;
     var status = document.sms.status.value;
     var action = document.sms.action.value;
     var BR = '\n';
     
     sms = sms + '<textarea name="template" rows="10" cols="55">';
     sms = sms + 'Service Impacted: '+ impact + BR;
     sms = sms + 'Service Status  : '+ status + BR;
     sms = sms + 'Next Action     : '+ action + BR;
     sms = sms + '</textarea>';

     document.getElementById('sms').innerHTML=sms;
     //document.getElementById('blank').innerHTML='';
  }
// ]]>
</script>

hope it helps...


It works! thank you so much you are a legend!

leviathan185
Junior Poster
105 posts since May 2009
Reputation Points: 19
Solved Threads: 15
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You