HTML tags read as string in createTexNode

Javascript coding ..

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 14
Joined: Mon Jan 09, 2012 12:05 am

HTML tags read as string in createTexNode

Postby lonelygirl86 » Tue Jan 31, 2012 9:50 pm

Please look at my script below:

Code: Select all

// sample data: username_designation='Juan de La Cruz (<i>President</i>)';
function addSelected(username_designation, userid){
    var new_row = document.createElement( 'tr' );
   var name_td = document.createElement( 'td' );
   name_td.className = 'tdcolor';
   name_td.appendChild( document.createTextNode( user_name ) );
  return true;

The output of that function became "Juan de La Cruz (<i>President</i>)".
It should be like this Juan de La Cruz (President). The html tags are being read as a string. I checked the source code, < is being converted to &lt; and > = &gt;

As what i have read, i will used innerHtml but i dont know how. Can someone give me hint?

Return to “JavaScript”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest