Click to See Complete Forum and Search --> : Currency Symbols assigning valuess


lingra
09-01-2003, 01:18 PM
I need to assign to a readonly input field the code for a special currency symbol.

example.
<script>
document.forms[form].currsymbol.value="€"
</script>


<INPUT TYPE="text" NAME="currsymbol" readonly>

This is the code for the euro. The problem is that the code gets displayed instead of the symbol.

How do you assign the value of a special character so that it prints the special character instead of the code?

:confused:

gil davis
09-01-2003, 01:22 PM
In my browser (IE 5.5 on W98SE), I see the symbol rather than the code.

Are you sure your browser understands the code for the Euro symbol?

lingra
09-01-2003, 02:36 PM
if I hard code the code in the input statement:

<INPUT TYPE="text" NAME="currsymbol" value="€" readonly>

it prints the symbol, but when I try to assign the value from a javascript, it shows the code "& # 8 3 6 4 ;" (double spaced so the code would show.

In this code the part1 shows the symbol, part2 shows the code:

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

<body>
<form name="formx">
<input type="text" name="part1" value="€">
<input type="text" name="part2" >
</form>

<script language=javascript>
document.formx.part2.value="€";
</script>

</body>
</html>

I need to be able to assign the currency symbol depending on whether it is a pound, euro, dollar, etc.

lingra
09-01-2003, 02:38 PM
in the above code, the code is showing as the symbol.

in the script i have the code " & #8364;" (no spaces)

gil davis
09-02-2003, 09:44 AM
You don't need the quotes around it. It makes it a string value.
document.formx.part2.value = &amp;#8364;

lingra
09-02-2003, 09:59 AM
Gil, when I do that it gives me an syntax error.

gil davis
09-02-2003, 09:21 PM
Sorry. Of cource it would. You cannot have HTML inside a script.
document.formx.part2.value = String.fromCharCode(8364);