2

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.

1
  • Please add more details to your question. post the code you tried here if possible. Jun 18, 2019 at 5:53

2 Answers 2

0

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

2
  • when we fetch the data <br> tag also comes.So in array we have to do splitting? Jun 19, 2019 at 7:07
  • You don't need to add <br> only define width, when it will reach end of width, data will shift to another line Jun 20, 2019 at 11:04
0

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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