0

I have a textbox and i have values in database like ® which is equal to ® .I fetch data and write it into textbox but it writes the data as it is.The code part is like this

var data=database_values;//here there is data like this "DOLBY®"
document.getElementById(id).value = data;

I want to make the textbox value DOLBY® not DOLBY®

MrSmith42
  • 9,961
  • 6
  • 38
  • 49
Hüseyin BABAL
  • 15,400
  • 4
  • 51
  • 73
  • As I understand your database value is & #174; and the textbox show & #174; and not (R);. What database do you use? most of them can use special character set and store (R);. – HamoriZ Nov 09 '10 at 07:55
  • @Zoltan Hamori, most databases `can` store special characters does not mean that we have to. There are reasons for storing escaped values. – Nivas Nov 09 '10 at 08:01

3 Answers3

0

If you are getting ® as ® then unescape it.

document.getElementById(id).value = unescape(data);

Nivas
  • 18,126
  • 4
  • 62
  • 76
0

Assuming you're using a server side language (i.e php) there are functions for that.

for example this will work with php:

html_entity_decode($data);

if you're set on using javascript, there's still a way. see the code here.

Yonizaf
  • 44
  • 3
0

Hi i found a way to unescape html code.Here is the function

function unescapeHTML(html) {
var tempHtmlNode = document.createElement("tempDiv");
tempHtmlNode.innerHTML = html;
if(tempHtmlNode.innerText)
return tempHtmlNode.innerText; // IE
return tempHtmlNode.textContent; // FF

}

Thanks for your help anyway

Hüseyin BABAL
  • 15,400
  • 4
  • 51
  • 73