JS for textarea in HTML form - POST request not sending textarea

Viewed 231

I am using pure JS to add options to a textarea, namely using SunEditor.

The JS is rendered in the front-end's textarea tag, but the input/content created is not being saved/POSTed to the the server via the form's POST request.

Can someone please point me where am I going wrong?

<textarea id="w3review" name="w3review"></textarea>
<script>
    const editor = SUNEDITOR.create('w3review', {
        font: ['Arial'],
        buttonList: [['font', 'fontSize']],
        callBackSave: function(contents) {}
    });

    const contents = editor.getContents();
</script>
1 Answers

The textarea does not have a name attribute, this is required for POST requests. the id attribute is primarily for JavaScript.

Try this for your textarea:

<textarea id="w3review" name="w3review"></textarea>

Related