Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7430747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:11:23+00:00 2026-05-29T09:11:23+00:00

This is an extension of a previous question I asked. I ran into some

  • 0

This is an extension of a previous question I asked. I ran into some additional issues.

I am loading a form with dynamic textarea boxes. Don’t ask why, but I need to populate these fields using JavaScript (has to deal with AJAX stuff, etc). To simplify things, let’s just say my textarea has a name of “myTextarea” and I want to populate with a request parameter “myRequestParam”. So I’d want to do something like:

updateTextareaText("myTextarea", "${myRequestParameter}");

From my previous question, I’ve found that this solves some issues:

updateTextareaText("myTextarea", unescape('<c:out value="${myRequestParam}" />'));

I have tried a number of different implementations for updateTextareaText, but nothing seems to work. I need to handle both newlines and special characters.

Try #1

function updateTextareaText(textareaElementName, newText) {
    var textareaBox = document.getElementsByName(textareaElementName)[0];
    textareaBox.innerHTML = newText;
}

Try #2

function updateTextareaText(textareaElementName, newText) {
    var textareaBox = document.getElementsByName(textareaElementName)[0];
    textareaBox.value = newText;
}

Try #3

function updateTextareaText(textareaElementName, newText) {
    var textareaBox = document.getElementsByName(textareaElementName)[0];

    var existingNodes = textareaBox.childNodes;
    if (existingNodes.length > 0) {
        textareaBox.removeChild(existingNodes[0]);
    }

    var newTextNode = document.createTextNode(newText);
    textareaBox.appendChild(newTextNode);
}

All of the above loose newlines and/or displays some special characters as their escaped values. I’ve been using the following myRequestParam value for testing:

Test

Newline and Special `~!@#$%^&*()_+-={}|[]\:";'<>?,./

Does anyone know the correct way to handle all of the different cases? As a side note, the myRequestParam values are populated from the DB and are returning newlines as \r\n which I have been escaping as %0A, but I am not sure if that’s what I should be doing. The JavaScript originally wouldn’t handle the \r\n (it would complain about unterminated strings, etc).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:11:24+00:00Added an answer on May 29, 2026 at 9:11 am

    See another question that I submitted. The trick was to remove the escaping from the backside and the whole escape and <c:out> stuff and instead use an EL function that utilizes StringEscapeUtils.escapeJavaScript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an extension to a question which I asked some time ago. I
(Note: This is an extension of a previous question .) I am having some
this is an extension to a previous question I asked , today .... which
this question is an extension to a previous question i asked (and was answered).
This is an extension of a question I previously asked here . Long story
This is an extension for this question asked an hour ago. We cannot modify
This is an extension / next step of this question I asked a few
Sorry for the redundancy, I should've asked this in my previous question here: What's
Hello every one this is extension to my previous question.Here is the link File
This is an extension to a previous question which was answered. But have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.