# Javascript to update a rich text field

**URL:** <https://forums.knack.com/t/javascript-to-update-a-rich-text-field/6824>\
**Category:** API & Custom Code\
**Created:** [February 12, 2019, 11:17am UTC](https://forums.knack.com/t/javascript-to-update-a-rich-text-field/6824 "2019-02-12T11:17:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BradStevens](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/bradstevens/32/140_2.png) [@BradStevens](https://forums.knack.com/u/BradStevens)\
**Post date:** [February 12, 2019, 11:17am UTC](https://forums.knack.com/t/javascript-to-update-a-rich-text-field/6824/1 "2019-02-12T11:17:18Z")

</div>

Thought I'd share - I had a need to insert formatted data into a rich text field via Javascript, and thanks to Stakoverflow the key method is:

```
$('#field_XXX').redactor('code.set', htmltext);
```

 

Of course build the variable htmltext with html for it to work.
