AJAX, javascript problems
Hello,
I'm working on a chat based on PHP/mySQL and AJAX. I actually got the main script from a free download but now I need to modify it. To script js isn't that hard. The problem I have is to get my javascript to translate HTML and make an execute.
Here is how it goes:
1. Page load and get results from the db in a string looking like this: $id." ---".$name." ---".replace($text)." ---".myLongDateChat($posted)." ---";
2. The --- is later taken care of in the jsfile where they work as splitters of the string.
3. Then the js does this:
//inserts the new content into the page
function insertNewContent(liName,liText,liPosted) {
insertO = document.getElementById("outputList");
oLi = document.createElement('li');
oSpan2 = document.createElement('span');
oSpan = document.createElement('span');
oSpan2.setAttribute('className','name'); //for IE's sake
oSpan2.setAttribute('class','name');
oSpan.setAttribute('className','post'); //for IE's sake
oSpan.setAttribute('class','post');
oName = document.createTextNode(liName+': ');
oText = document.createTextNode(liText);
oPosted = document.createTextNode(liPosted);
oSpan2.appendChild(oName);
oSpan.appendChild(oPosted);
oLi.appendChild(oSpan);
oLi.appendChild(oSpan2);
oLi.appendChild(oText);
insertO.insertBefore(oLi, insertO.firstChild);
}
Setting some class names on the different values we got from the split.
4. Now I want the oText from the split to be able to print out my emoticons but all I get is: <img src="images/smilies/biggrin.gif" width="20" height="18" alt="" border="0">
My format from [biggrin] to <img src="images/smilies/biggrin.gif" width="20" height="18" alt="" border="0"> works perfect but the js won't execute my HTML.
Can anyone help me?
Kind regards,
Niklas
I'm working on a chat based on PHP/mySQL and AJAX. I actually got the main script from a free download but now I need to modify it. To script js isn't that hard. The problem I have is to get my javascript to translate HTML and make an execute.
Here is how it goes:
1. Page load and get results from the db in a string looking like this: $id." ---".$name." ---".replace($text)." ---".myLongDateChat($posted)." ---";
2. The --- is later taken care of in the jsfile where they work as splitters of the string.
3. Then the js does this:
//inserts the new content into the page
function insertNewContent(liName,liText,liPosted) {
insertO = document.getElementById("outputList");
oLi = document.createElement('li');
oSpan2 = document.createElement('span');
oSpan = document.createElement('span');
oSpan2.setAttribute('className','name'); //for IE's sake
oSpan2.setAttribute('class','name');
oSpan.setAttribute('className','post'); //for IE's sake
oSpan.setAttribute('class','post');
oName = document.createTextNode(liName+': ');
oText = document.createTextNode(liText);
oPosted = document.createTextNode(liPosted);
oSpan2.appendChild(oName);
oSpan.appendChild(oPosted);
oLi.appendChild(oSpan);
oLi.appendChild(oSpan2);
oLi.appendChild(oText);
insertO.insertBefore(oLi, insertO.firstChild);
}
Setting some class names on the different values we got from the split.
4. Now I want the oText from the split to be able to print out my emoticons but all I get is: <img src="images/smilies/biggrin.gif" width="20" height="18" alt="" border="0">
My format from [biggrin] to <img src="images/smilies/biggrin.gif" width="20" height="18" alt="" border="0"> works perfect but the js won't execute my HTML.
Can anyone help me?
Kind regards,
Niklas
niklas
August 17,