/    Sign up×
Community /Pin to ProfileBookmark

createTextNode

Hi, I have a simple function which takes some HTML bolded text and a table cell ID (both passed from PHP). On mouseover the text is displayed in the specified cell. The only problem is that the text is raw HTML and the bold tags show instead of bolding the text. How do I get the text to be displayed in its intended form? I have had at a bash using innerHTML but I can’t really code in Javascript. Here’s my code so far: –

function display(text,cellID){
var getText = document.getElementById(cellID);
getText.appendChild(document.createTextNode(text));
}

Thanks

Solaar

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@lijosSep 20.2006 — Did you try this?

[code=php]
function display(text,cellID) {
document.getElementById(cellID).innerHTML += text;
}
[/code]
Copy linkTweet thisAlerts:
@SolaarauthorSep 20.2006 — I have now, thanks very much. I don't suppose there's a limit on the length of the string the function will accept. If 'text' is too long nothing shows.
Copy linkTweet thisAlerts:
@lijosSep 21.2006 — It depends on the browser, but any modern browser should handle atleast 2000 chars.
×

Success!

Help @Solaar spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...