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

Javascript: text converting into ASCII codes

P: 58
Hello frens,

Its really a gr8 network community. Ususlly i get the response really in very small time. Today again i am having small doubt :-)

Actually i am working on an application built using j2ee/java struts/java script.
Here, i have set some names in the view bean say "king's kingdom". Now when i am trying to use this name from the viewbean on the jsp using the javascrip , it is getting changed to something like this "king's kingdom" and the text "Harvey on Industrial Relations & Employment Law Cases" is getting changed to "Harvey on Industrial Relations & Employment Law Cases". Can anyone please help me so that i can display the original text to the user.
Jan 15 '08 #1
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
How are these values entered and stored in the first place? Can you show the JavaScript code?
Jan 15 '08 #2

P: 58
How are these values entered and stored in the first place? Can you show the JavaScript code?
Hi Acoder,

i am setting these values in my action class in the view bean as a list of the some object. and this object carries these texts. Now in my jsp i am iterating on the viewbean list and storing the contents in javascript object something like this:

arr[0] = new searchSource("name1 having appostrophysay King's Kingdom from viewbean");
arr[0] = new searchSource("second name from viewbean");

here searchSource is a javaScript object as follows
function searchSource(name){
this.name = name;
}

now i am trying to show these names from this object into the option tag of a select tag as folllows:

document.getElementById('idOfSelectTag").options[0] = arr[0].name;

now here, what i see in the option of the select as the ASCII conversion of the appostrophy(') as told above post.
Jan 15 '08 #3

acoder
Expert Mod 15k+
P: 16,027
You could try using the encode/decode functions, e.g. encodeURIComponent.
Jan 16 '08 #4

P: 58
You could try using the encode/decode functions, e.g. encodeURIComponent.
Hey ,
Acoder
Still the issue is not resolved. The apostrophy ' is converting into "&hash039;s" and "&" converting into &amp
Feb 18 '08 #5

acoder
Expert Mod 15k+
P: 16,027
I don't see this problem. Can you give a sample page which demonstrates the problem? Does this affect all browsers or one particular one?
Feb 18 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.