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

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: May 2009
Posts: 101
Reputation: leviathan185 is an unknown quantity at this point 
Solved Threads: 14
leviathan185's Avatar
leviathan185 leviathan185 is offline Offline
Junior Poster

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

 
0
  #1
Aug 26th, 2009
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.

  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
@ I'm gonna live forever, or die trying.

@ A wise man once told me, in order to understand recursion, you first must understand recursion.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 81
Reputation: AshtonHogan is an unknown quantity at this point 
Solved Threads: 1
AshtonHogan AshtonHogan is offline Offline
Junior Poster in Training

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

 
0
  #2
Aug 26th, 2009
Have you tried escape characters? \n ?
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 101
Reputation: leviathan185 is an unknown quantity at this point 
Solved Threads: 14
leviathan185's Avatar
leviathan185 leviathan185 is offline Offline
Junior Poster

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

 
0
  #3
Aug 26th, 2009
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
@ I'm gonna live forever, or die trying.

@ A wise man once told me, in order to understand recursion, you first must understand recursion.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

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

 
0
  #4
Aug 26th, 2009
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...
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 101
Reputation: leviathan185 is an unknown quantity at this point 
Solved Threads: 14
leviathan185's Avatar
leviathan185 leviathan185 is offline Offline
Junior Poster

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

 
0
  #5
Aug 26th, 2009
Originally Posted by essential View Post
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!
@ I'm gonna live forever, or die trying.

@ A wise man once told me, in order to understand recursion, you first must understand recursion.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC