943,590 Members | Top Members by Rank

Ad:
Aug 26th, 2009
0

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

Expand Post »
I have written some code for template generator but I am having issue getting the formatting when it is generated in the <textarea></textarea>.

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 <br>

Service Impacted: data<br />Service Status : lost comms<brNext Action : carrier invest<br>

here is the code I have written.

html Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2.  
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4.  
  5. <head>
  6.  
  7. <script language="JavaScript">
  8.  
  9.  
  10. function generate()
  11.  
  12. {
  13.  
  14. var sms = ''
  15.  
  16.  
  17.  
  18. var impact = document.sms.impacted.value;
  19.  
  20. var status = document.sms.status.value;
  21.  
  22. var action = document.sms.action.value;
  23. var BR = '<br>'
  24.  
  25.  
  26. sms = sms + '<textarea name="template" rows="10" cols="55">';
  27.  
  28. sms = sms + 'Service Impacted: '+ impact + '<br />';
  29.  
  30. sms = sms + 'Service Status : '+ status + '<br>';
  31.  
  32. sms = sms + 'Next Action : '+ action +'<br>';
  33.  
  34. sms = sms + '</textarea>';
  35.  
  36.  
  37. document.getElementById('sms').innerHTML=sms;
  38.  
  39. //document.getElementById('blank').innerHTML='';
  40.  
  41. }
  42.  
  43. </script>
  44.  
  45. <link href="scripts/imt.css" rel="stylesheet" type="text/css" />
  46.  
  47. </head>
  48.  
  49. <body>
  50.  
  51. <script type="text/javascript">
  52.  
  53. <!--
  54.  
  55.  
  56.  
  57. -->
  58.  
  59. </script>
  60.  
  61.  
  62.  
  63. <div id="page">
  64.  
  65. <div id="wrapper">
  66.  
  67. <div id="header"></div>
  68.  
  69. <div id="topSpacer"></div>
  70.  
  71. <div id="body">&nbsp;
  72.  
  73. <h2 align="center">The Fault logging assistant</h2>
  74.  
  75. <h3 align="center"></h3>
  76.  
  77. <form name="sms" action="">
  78.  
  79. <table name="table" width="500" border="0" align="center">
  80.  
  81. <tr align="center">
  82.  
  83. <td colspan="2">
  84.  
  85. <h3>SMS Template Genterator</h3>
  86.  
  87. </td>
  88.  
  89. </tr>
  90.  
  91. <tr>
  92.  
  93. <td><strong>Service Impacted: </strong></td>
  94.  
  95. <td>
  96.  
  97. <input type="text" name="impacted" value="">
  98.  
  99. </td>
  100.  
  101. </tr>
  102.  
  103. <tr>
  104.  
  105. <td><strong>Service Status: </strong></td>
  106.  
  107. <td>
  108.  
  109. <input type="text" name="status" value="">
  110.  
  111. </td>
  112.  
  113. </tr>
  114.  
  115. <tr>
  116.  
  117. <td><strong>Next Action: </strong></td>
  118.  
  119. <td>
  120.  
  121. <input type="text" name="action" value="">
  122.  
  123. </td>
  124.  
  125. </tr>
  126. <td><input type="button" name="button" value="Generate" onClick="generate()">
  127.  
  128. <tr>
  129.  
  130. </tr>
  131.  
  132. <tr>
  133.  
  134. <td colspan="2">
  135.  
  136. <span id='sms'></span>
  137.  
  138. </td>
  139.  
  140. </tr>
  141.  
  142. </table>
  143.  
  144. <span id="blank"></span>
  145.  
  146. </form>
  147.  
  148.  
  149. </div>
  150.  
  151. <div id="bottomSpacer"></div>
  152.  
  153. <div id="footer">
  154.  
  155.  
  156.  
  157. </div>
  158.  
  159. </div>
  160.  
  161. </div>
  162.  
  163. </body>
  164.  
  165. </html>
Last edited by leviathan185; Aug 26th, 2009 at 9:32 am. Reason: remove personal info
Similar Threads
Reputation Points: 19
Solved Threads: 15
Junior Poster
leviathan185 is offline Offline
105 posts
since May 2009
Aug 26th, 2009
0

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

Have you tried escape characters? \n ?
Reputation Points: 7
Solved Threads: 1
Posting Whiz in Training
AshtonHogan is online now Online
209 posts
since Jul 2009
Aug 26th, 2009
0

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

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
Reputation Points: 19
Solved Threads: 15
Junior Poster
leviathan185 is offline Offline
105 posts
since May 2009
Aug 26th, 2009
0

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

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...
Featured Poster
Reputation Points: 114
Solved Threads: 138
Posting Shark
essential is offline Offline
973 posts
since Aug 2008
Aug 26th, 2009
0

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

Click to Expand / Collapse  Quote originally posted by essential ...
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!
Reputation Points: 19
Solved Threads: 15
Junior Poster
leviathan185 is offline Offline
105 posts
since May 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Need a DIV always at bootm by my way!
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Problem with pop up on my javascript





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC