Reply to Re: How to convert HTML special characters to the real characters with a Java script

Your name:

Reply:


Posted by Jerry Stuckle on 03/21/06 21:39

Stefan Mueller wrote:
> I read data (e.g. äöüÄÖÜçéàè"') from my MySQL database which I'd like to
> show in an input box.
>
> <?php
> $mysql_data = "äöüÄÖÜçéàè\"'";
> $html_data = addslashes(htmlentities($mysql_data, ENT_QUOTES));
>
> echo "<script type = 'text/javascript'>";
> echo "function set_old_data() {";
> echo "my_form.input1.value = var_old_data;";
> echo "}";
> echo "var_old_data = '" . $html_data . "';";
> echo "</script>";
>
> echo "<body>";
> echo "<form name = 'my_form' action = '' method = 'post' accept-charset
> = 'iso-8859-1'>";
> echo "<input type = 'text' name = 'input1' value = '" . $html_data .
> "'>";
> echo "<input type = 'button' value = 'Old Data' onClick =
> 'set_old_data()'>";
> echo "</form>";
> echo "</body>";
> ?>
>
> The command
> echo "<input type = 'text' name = 'input1' value = '" . $html_data . "'>";
> shows my data äöüÄÖÜçéàè"' in the input box perfect.
>
> But if I click on the button 'Old Data' the Java script function
> 'set_old_data' shows in the input box
> &auml;&ouml;&uuml;&Auml;&Ouml;&Uuml;&ccedil;&eacute;&agrave;&egrave;&quot;&#039;
> instead of
> äöüÄÖÜçéàè"'
>
> Therefore I need a Java script function with translates
> &auml;&ouml;&uuml;&Auml;&Ouml;&Uuml;&ccedil;&eacute;&agrave;&egrave;&quot;&#039;
> to
> äöüÄÖÜçéàè"'
>
> In PHP I could do that with the function
> html_entity_decode()
>
> But how can I do it with a Java script?
> Stefan
>
> PS: html_entity_decode() is the opposite of htmlentities(). It converts all
> HTML entities to their applicable characters from string.
>
>

Uh, maybe ask in a Javascript newsgroup?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация