By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,886 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

Treating Special Characters

P: n/a
I have a number of scripts that take special characters and convert them
to their ascii equivalents and them store them in the database.

However I am running into a problem that I have some of those fields are
loaded to an array and inserted into cells dynamically. As an example
the array would be:

var my_array = [ ["52","Source Data"], ["19","Body &
Soap"] ];

Then I have some javascript that creates the cell and inserts the value
into a cell text node like:

var x = my_array[1][1]; // this would be "Body & Soap"

//create the cell
myTD=document.createElement("TD");

//create the text node
myText=document.createTextNode(x);

// Appends each node following the structure.
myTD.appendChild(myText);

What I see on the output is: "Body & Soap"

What I should see is: "Body & Soap"

Anyone know how to get around this?

Mike

Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


Michael Hill wrote:

However I am running into a problem that I have some of those fields are
loaded to an array and inserted into cells dynamically. As an example
the array would be:

var my_array = [ ["52","Source Data"], ["19","Body &
Soap"] ];

Then I have some javascript that creates the cell and inserts the value
into a cell text node like:

var x = my_array[1][1]; // this would be "Body & Soap"

//create the cell
myTD=document.createElement("TD");

//create the text node
myText=document.createTextNode(x);

// Appends each node following the structure.
myTD.appendChild(myText);

What I see on the output is: "Body & Soap"

What I should see is: "Body & Soap"


No, what you see is correct, you create a text node with the content
Body & Soap
and that is what you see.
If you want to have the ampersand literally then store
"Body & Soap"
in the JavaScript string.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.