Wednesday, 7 September 2011

Retrieving Rich Text Box value using JavaScript in SharePoint

Few days back I was working on one requirement to customize SharePoint list form(newform.aspx) using SharePoint designer 2007.

And I was unable to retrieve value from Rich Text box field "Analysis" in JavaScript.

I solved my issue using below JavaScript

<script type="text/javascript">

 var varAnalysis = getTagFromIdentifierAndTitle("textarea","TextField","Analysis*");
 var varAnalysisTextBoxID = RTE_GetEditorDocument(;
 var varAnalysisText = varAnalysisTextBoxID.body.innerText;

function getTagFromIdentifierAndTitle(tagName, identifier, title)
 var len = identifier.length;
 var tags = document.getElementsByTagName(tagName);
 for (var i=0; i < tags.length; i++)
  var tempString = tags[i].id;
  if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len))
   return tags[i];
 return null;

This code solved my problem.


  1. Hi Pawan,

    in above code, i'm facing an issue. every time 'IF" condition is failing in side the function defination.

  2. Hi Sp,
    May be your problem has been solved now.

    But this code was tested on MOSS 2007 and that time it was working. I have not used this in SP 2010 though.
    This function "getTagFromIdentifierAndTitle(tagName, identifier, title)" is available on MS Sharepoint designer blog at below link:


Related Posts Plugin for WordPress, Blogger...