function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GrantMGrantM 

carriage returns cause javascript error on render

Hi,
 
I have an S-Control that is calling a description field into a textarea.
When this description field has a carriage return, it causes a Javascript error
 
S-Control Code:
Code:
output += "<input>{!Opportunity.Description}</input>";

 
Rendered as:
Code:
output += "<input>this is line 1
this is line 2</input>";

 What is the suggested way around this?
 
TIA
cheenathcheenath
One option will be to put the mege filed in a hidden text area.
Something like:

<textarea id="id1">
 {!Opportunity.Description}
</textarea>

Then in your javascript you can get the text as:

output += document.getElementById("id1").value;


HTHs,



GrantMGrantM
Ahhhh, seems obvious now :)
 
Thanks!!
GrantMGrantM
I keep receiving this error when i try call that value:
 
'document.getElementById(...)' is null or not an object
 
Any ideas?
GrantMGrantM
woops, i had stupidly removed a DIV tag that was being reference somewhere else onthe page.
 
SOrry, that answer was spot on!!