473,587 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Treating Special Characters

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","Sourc e 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.c reateElement("T D");

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

// Appends each node following the structure.
myTD.appendChil d(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
1 1424


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","Sourc e 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.c reateElement("T D");

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

// Appends each node following the structure.
myTD.appendChil d(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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
8980
by: Roy W. Andersen | last post by:
I've been searching google about this for days but can't find anything, so I'm hoping someone here can help me out. I'm trying to create zip-files without needing the zip-file extension in PHP, mainly because I need the ability to both create and extract zip-files. I've tried a couple of classes found here and there, and they all seem to...
3
17191
by: Barry Olly | last post by:
Hi, I'm working on a mini content management system and need help with dealing with special characters. The input are taken from html form which are then stored into a varchar column in oracle database. When i retrieve the data, some of the special characters have been changed to ??? and also
8
1862
by: Raymond Hettinger | last post by:
Comments are invited on the following proposed PEP. Raymond Hettinger ------------------------------------------------------- PEP: 329
5
8611
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file". Same file path containing special characters works fine in one machine, but doesn't work in other. I am using following API function to get short...
8
3653
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box and save it to a file. This step is not to hard however the contents of the textarea is mostly latex source so it contains just about every special...
1
4558
by: sonald | last post by:
Dear All, I am working on a module that validates the provided CSV data in a text format, which must be in a predefined format. We check for the : 1. Number of fields provided in the text file, 2. Text checks for max. length of the field & whether the field is mandatory or optional Example:
6
1642
by: Bart Lateur | last post by:
A word of warning for you people who write their scripts and test them on a single platform. Even in this day and age, when portability of Javascript is a lot higher than it used to be, it might still bite you in the arse. For example. Try to run this in Firefox: s = "ACE"; alert(s ); You'll see a textbox showing a "C", the second...
3
10189
KevinADC
by: KevinADC | last post by:
Purpose The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and some special characters inside a character class. This is not a regular expression tutorial. Assumes you are already familiar with basic regular expression concepts and terminology. If not, you may want...
0
1975
by: AAaron123 | last post by:
Been playing with asp:changepassword and have it looking OK except that I can't elininate or change the title at the top that says "Change Your Password". It's a repeat of my pages title. But more importantly, I can't find the regular expression for at least 7 characters and at least 1 special character. Can you help?
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.