I need get a variable value from XSLT in search result in SharePoint 2010. But this value is muti-lines text. When I add this variable value in JavaScript, the JS code cannot work, because the line break. How can I remove line break from text ? Or remove them directely in XSLT ?

<!DOCTYPE html>

<p>Click the button to convert different objects to strings.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

function myFunction() {
var x1 = '<xsl:value-of select="$information"/>';

//The contents of this variable value
'To submit your request, plase contact Mr XX 

HR request (for HR only!!!)

           Warning : Offre available for people working in HR

  This request allows you to modify your account name.
Thank you';
//End of contents

var res = String(x1);
document.getElementById("demo").innerHTML = res;


Finally, I found how to modify the code. I change this

var x1 ='<xsl:value-of select="$information"/>'; 


var info = thisitem.parentNode.getElementsByTagName('div');
var x=info[0].innerHTML;

"thisitem" is a variable value

It works!!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.