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 8335655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:44:15+00:00 2026-06-09T03:44:15+00:00

I got this nice code, which I have no idea why doesn’t work. It

  • 0

I got this nice code, which I have no idea why doesn’t work. It should get the value of a text input and replace each given national character with it’s HTML code, for compatibility purposes. But, when I click the button, the function returns the string without any changes.
Any idea?

(jsfiddle)

<a id="reminder1" onclick="document.getElementById('reminder2').style.display = ''; document.getElementById('reminder1').style.display = 'none';">
    Set reminder
</a>
<a id="reminder2" class="reminder" style="display:none;">
    <input type="text" id="reminderh" size=40 style="font-size:20px;">
    <input type="button" value="Set" onclick="csere(document.getElementById('reminderh').value);">
</a>

<script>
function csere(qwe){
document.getElementById('reminder2').style.display = 'none';

var rtz0  = qwe.replace("á","&aacute;");
var rtz1  = rtz0.replace("Á","&Aacute;");

var rtz2  = rtz1.replace("é","&eacute;");
var rtz3  = rtz2.replace("É","&Eacute;");

var rtz4  = rtz3.replace("í","&iacute;");
var rtz5  = rtz4.replace("Í","&Iacute;");

var rtz6  = rtz5.replace("ö","&ouml;");
var rtz7  = rtz6.replace("Ö","&Ouml;");
var rtz8  = rtz7.replace("ő","&&#337;");
var rtz9  = rtz8.replace("Ő","&#336;");
var rtz10 = rtz9.replace("ó","&oacute;");
var rtz11 = rtz10.replace("Ó","&Oacute;");

var rtz12 = rtz11.replace("ü","&uuml;");
var rtz13 = rtz12.replace("Ü","&Uuml;");
var rtz14 = rtz13.replace("ű","&#369;");
var rtz15 = rtz14.replace("Ű","&#368;");
var rtz16 = rtz15.replace("ú","&uacute;");
var uio = rtz16.replace("Ú","&Uacute;");

//Creates a cookie with the final value (different function)
createCookie('reminder',uio,1500);

document.getElementById('reminder1').style.display = '';
}
</script>
  • 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-06-09T03:44:16+00:00Added an answer on June 9, 2026 at 3:44 am

    You can just replace everything programmatically, not using named entities:

    return input.replace(/[^ -~]/g, function(chr) {
    //                    ^^^^^^ 
    // this is a regexp for "everything than printable ASCII-characters"
    // and even works in a ASCII-only charset. Identic: [^\u0020-\u007E]
        return "&#"+chr.charCodeAt(0)+";";
    });
    

    If you want to use named entities, you can combine this with a key-value-map (as like in @jackwanders answer):

    var chars = {
        "á" : "&aacute;",
        "Á" : "&Aacute;",
        "é" : "&eacute;",
        "É" : "&Eacute;",
        ...
    }
    return input.replace(/[^ -~]/g, function(chr) {
        return (chr in chars) 
          ? chars[chr]
          : "&#"+chr.charCodeAt(0)+";";
    });
    

    However, you should never need to use html entities in JavaScript. Use UTF8 as the character encoding for everything, and it will work.

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

Sidebar

Related Questions

Hey, I've got this nice little piece of code, much like all the other
I have just written some code, which as i was writing i thought, this
Got this line of code here but its not working. private void Button_Click(object sender,
Got this code for a viewscroller from the apple developers site. @synthesize scrollView1, scrollView2;
I got this code from our frontend guy for headings: <h2 class=headline><span>Foobar</span></h2> The span
We've got a .NET project at work, which we lost (human error). The person
This has got to be one of the most frustratingly stupid bugs I have
So I've got this nice Android game (a snake-clone with animations), doing the final
I've got some code which accepts a DataTable as a parameter and calculates the
Okay, so I've got some C code to perform a mathematical operation which could,

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.