Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

So I am using JQuery to create a button in a SharePoint Discussion List that then takes me to a create new project form and then on this form have JQuery pulling the content I want from the Discussion List and dropping it in the RTE text area and that works fine except it brings ALL the html tags with it eg.

ect..

Here is my code below, I need to find out how to remove these tags and keep the formatting.

JavaScript
function GetParam(name)
 	{
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		var regexS = "[\\?&]"+name+"=([^]*)";
		var regex = new RegExp( regexS );
		var results = regex.exec( unescape(window.location.href) );
		if( results == null )
		return "";
		else
		return results[1];
 	}

	
$(document).ready(function() {
	
	//SP2010AddNewify("Customer","/International/Lists/mE%20Clients/NewForm.aspx", "mE Clients");
	ExecuteOrDelayUntilScriptLoaded(GetBlogBody, "sp.js");	
		
});

//////////////////////////////////////////////////////////////////////////
/////////////////////////////////GET ITEM////////////////////////////////


function GetBlogBody() {

  
    
    var id = GetParam("blogid");
    var clientContext = SP.ClientContext.get_current();
    var oList = clientContext.get_web().get_lists().getByTitle('Team Discussion');     
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml("<view><query><where><eq><fieldref name="ID" /><value type="Counter">" + id + "</value></eq></where></query></view>");
    //camlQuery.set_viewXml("<view><query><where><eq><fieldref name="Title" /><value type="Text">Mandarin prices</value></eq></where></query></view>");       
    this.collListItem = oList.getItems(camlQuery);     
    clientContext.load(collListItem);      
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));        
    
        
      
}

 


function onQuerySucceeded(sender, args) {
	//alert('Query Success');
    var listItemInfo = '';
    
    var listItemEnumerator = collListItem.getEnumerator();
    var contentbody = "";
                
    while (listItemEnumerator.moveNext()) {
    var oListItem = listItemEnumerator.get_current();
    				      contentbody = oListItem.get_item('Body');         
                               
	}//  end while
     
     
	 
    
     CopyBodyToDescription(contentbody);
     //alert(CopyBodyToDescription);
                                                                      
                               
 		                

} // End Function


function CopyBodyToDescription(contentbody) {
		
		var systemDescriptionRTETextArea = $("textarea[Title='Description']");
		//alert($(systemDescriptionRTETextArea).html());
		$(systemDescriptionRTETextArea).html(contentbody);
		//alert($(systemDescriptionRTETextArea).html());
		
		
}//  End Function


function onQueryFailed(sender, args) {
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////


</script>

Posted
Updated 10-Sep-13 4:01am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900