PDA

View Full Version : Special Characters



matilda
02-22-2008, 09:26 PM
Hi

Is it possible to write the division symbol or ÷ to a html text box with javascript?:confused:

I have done this before but since changing web hostings the symbol appears as a square.

Below are three lines from the script that used to work.
myvar4="";
var v= "" + myvar1[h] + " " +myvar4+" " + myvar2[h] + " = ";
document.quizform.question.value=v;

Any help gratefully recieved.

Cheers
Matilda

Nile
02-22-2008, 09:45 PM
myvar4="%";
var v= "" + myvar1[h] + " " +myvar4+" " + myvar2[h] + " = ";
document.quizform.question.value=v;
Should work. ;)

boogyman
02-22-2008, 09:46 PM
I believe http://www.asciitable.com/ will be helpful

the percentage sign character code is
%

Nile
02-22-2008, 09:48 PM
@boogyman
I had the same problem, it displays it normaly,
You have to put a:

[ COLOR="Black"][/COLOR]
In between one of the letters.

I beat you to it!

matilda
02-22-2008, 11:25 PM
myvar4="÷";
var v= "" + myvar1[h] + " " +myvar4+" " + myvar2[h] + " = ";
document.quizform.question.value=v;

does not work

the special character code displays rather than the divide symbol

Nile
02-22-2008, 11:38 PM
Can we see all of your js?
Also please wrap your codes with a
--- Things!

jscheuer1
02-23-2008, 04:05 PM
It may not matter how you get the character into the the value of the text input. This will do it (assuming that the rest of the code is correct):


myvar4="\xf7";
var v= "" + myvar1[h] + " " +myvar4+" " + myvar2[h] + " = ";
document.quizform.question.value=v;

But if the page isn't being served with a compatible charset, it will be replaced by a box, a question mark, etc.

I think this may be the problem, because you say it was working fine until you changed hosts. It is ultimately the host which determines the charset that a page is served with. You can use a meta tag to try to override this, but it may not always work, try this one:


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

in the head of the page, right after the title tag. Remove any other meta tags (if there are any others) that set the content and/or charset.

Be sure to clear the cache in your browser when viewing the changed page online.