I have a multi line rich text field and I want to get the data from column and set in text area line by line.
I tried Splitting but I need another solution if possible.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI have a multi line rich text field and I want to get the data from column and set in text area line by line.
I tried Splitting but I need another solution if possible.
You can do this easily by using p tag, i was also stucked on the same problem:
HTML part: <p id="location_of_work"></p>
Code:
$('#location_of_work').text(form1.location_of_work);
here form1 is my array from where i am getting values
location_of_work: column name
We can use REST API to get the multiple line of text field data, then set the text to textarea using jQuery. The following example code for your reference.
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
var listTitle="CustomList";
var fieldName="MultipleText";
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/items",
type: "GET",
headers: {
"Accept": "application/json;odata=verbose",
},
success: function (data) {
var text="";
$.each(data.d.results,function(i,item){
text+=$(item[fieldName]).text()+"\n";
});
$("#message").val(text);
},
error: function (data) {
alert(JSON.stringify(data));
}
});
});
</script>
<textarea id="message" rows="6" cols="80">
</textarea>