HTML tags read as string in createTexNode

Javascript coding ..

Moderators: egami, macek, gesf

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

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 < and > = >

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

Post Reply