Win a copy of Rust Web Development this week in the Other Languages forum!

Denis Williams

Greenhorn
+ Follow
since Dec 30, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Denis Williams

Incidentally I tried the & pound sign in the script contained in the body of a site I am building and it worked fine. where as the unicode would not work in this case. So it's horses for courses, at least when it comes to the UK currency sign.
Hi guy, You will be pleased to know I have found the solution, It's unicode. I changed my script to read like so:

document.getElementById("subtotal").value = "\u00A3" + subTotal.toFixed(2);
document.getElementById("tax").value = "\u00A3" + tax.toFixed(2);
document.getElementById("total").value = "\u00A3" + total.toFixed(2);

The unicode for the � is in Bold. I ran this and it worked perfectly. I posted the solution for other users benefit.

Thank you for your efforts and the time you have spent assisting me with this problem. Currency appears to be a difficult area to find solutions for. Once again your help has been much appreciated.

Regards Denis, javascript:%20x()


It works if I use it in the post on this forum thats why I ended up repeating my earlier post to Galen?

I'm completely foxed?
sorry it returned & pound;1.00
Hi Ulf, I followed your guide and added the semicolon like so "& pound;" without the space between & and pound, and when i ran my file it returned £1.09 instead of �1.09
Hello Galen. Sorry about the above post, I meant to say that as I am still learning I was still unclear how to put the £ or £ into my script. I have this script:

document.getElementById("subtotal").value = "�" + subTotal.toFixed(2);
document.getElementById("tax").value = "�" + tax.toFixed(2);
document.getElementById("total").value = "�" + total.toFixed(2);

So I presumed you meant I should substitute either & pound or & # 163 for the � sign like so:

document.getElementById("subtotal").value = "& # 163" + subTotal.toFixed(2);
document.getElementById("tax").value = "& # 163" + tax.toFixed(2);
document.getElementById("total").value = "& # 163" + total.toFixed(2);

However when I tried it, it didn't work. the result

was to show the & # 163 plus the price

Can you please point out where I am going wrong?

sorry I'm such a dumbo,

Regards Denis
Hello Galen. Sorry about the above post, I meant to say that as I am still learning I was still unclear how to put the £ or £ into my script. I have this script:

document.getElementById("subtotal").value = "�" + subTotal.toFixed(2);
document.getElementById("tax").value = "�" + tax.toFixed(2);
document.getElementById("total").value = "�" + total.toFixed(2);

So I presumed you meant I should substitute either & pound or & # 163 for the � sign like so:

document.getElementById("subtotal").value = "& # 163" + subTotal.toFixed(2);
document.getElementById("tax").value = "& # 163" + tax.toFixed(2);
document.getElementById("total").value = "& # 163" + total.toFixed(2);

However when I tried it, it didn't work. Can you please point out where I am going wrong?

sorry I'm such a dumbo,

Regards Denis
Hello Galen. Sorry about the above post, I meant to say that as I am still learning I was still unclear how to put the £ or £ into my script. I have this script:

document.getElementById("subtotal").value = "�" + subTotal.toFixed(2);
document.getElementById("tax").value = "�" + tax.toFixed(2);
document.getElementById("total").value = "�" + total.toFixed(2);

So I presumed you meant I should substitute either & pound or & # 163 for the � sign like so:

document.getElementById("subtotal").value = "& # 163" + subTotal.toFixed(2);
document.getElementById("tax").value = "& # 163" + tax.toFixed(2);
document.getElementById("total").value = "& # 163" + total.toFixed(2);

However when I tried it, it didn't work. Can you please point out where I am going wrong?

sorry I'm such a dumbo,

Regards Denis
Hello Galen. Sorry about the above post, I meant to say that as I am still learning I was still unclear how to put the £ or £ into my script. I have this script:

document.getElementById("subtotal").value = "�" + subTotal.toFixed(2);
document.getElementById("tax").value = "�" + tax.toFixed(2);
document.getElementById("total").value = "�" + total.toFixed(2);

So I presumed you meant I should substitute either £ or £ for the � like so:

document.getElementById("subtotal").value = "£" + subTotal.toFixed(2);
document.getElementById("tax").value = "£" + tax.toFixed(2);
document.getElementById("total").value = "£" + total.toFixed(2);

However when I tried it, it didn't work. Can you please point out where I am going wrong?

sorry I'm such a dumbo,

Regards Denis
Hello Galen. Thank you for your post. If you not already realised I know next to nothing about JS yet so please forgive me if the answer to my question seems obvious to you! I looked at your post and I presumed that I should insert £ or £ in my code like so:

document.getElementById("subtotal").value = "£" + subTotal.toFixed(2);
document.getElementById("tax").value = "£" + tax.toFixed(2);
document.getElementById("total").value = "£" + total.toFixed(2);

However when I tried it, it didn't work. Can you see if i have gone wrong please?
Hello Ulf, Thanks for your replies, but I'm still not clear as to what I need to do! the code I quoted is the only file containing the � sign (which I put in in place of $ sign) i.e. from this:

document.getElementById("subtotal").value = "$" + subTotal.toFixed(2);
document.getElementById("tax").value = "$" + tax.toFixed(2);
document.getElementById("total").value = "$" + total.toFixed(2);

to this:

document.getElementById("subtotal").value = "�" + subTotal.toFixed(2);
document.getElementById("tax").value = "�" + tax.toFixed(2);
document.getElementById("total").value = "�" + total.toFixed(2);



so should I be be putting the A0 Hexadecimal number somewhere in this file and if so where?

The body of the file is below:


&it body &it
&it div id="frame" &it
&it div class="heading" &it Duncan's Just-In-Time Donuts &it/div &it
&it div class="subheading" &it All donuts 50 pence each, cake or glazed! &it /div &it
&it div id="left" &it
&it img src="donuttime.png" alt="Just-In-Time Donuts" /& it
& it/div &it
&it form name="orderform" action="donuts.php" method="POST" &it
<div class="field" &it
Name: & it input type="text" id="name" name="name" value="" / &it
&it /div &it
&it div class="field" &it
# of cake donuts: &it input type="text" id="cakedonuts" name="cakedonuts" value=""
onchange="updateOrder();" / &it
&it /div &it
&it div class="field" &it
# of glazed donuts: &it input type="text" id="glazeddonuts" name="glazeddonuts" value=""
onchange="updateOrder();" / &it
&it /div &it
&it div class="field" &it
Minutes 'til pickup: &it input type="text" id="pickupminutes" name="pickupminutes" value="" / &it
&it /div &it
&it div class="field" &it
Subtotal: &it input type="text" id="subtotal" name="subtotal" value="" readonly="readonly" / &it
&it /div &it
&it div class="field" &it
Tax: &it input type="text" id="tax" name="tax" value="" readonly="readonly" / &it
&it /div &it
&it div class="field" &it
Total: &it input type="text" id="total" name="total" value="" readonly="readonly" / &it
&it /div &it
&it div class="field" &it
&it input type="button" value="Place Order" onclik="placeOrder(this.form);" / &it
&it /div &it
&it /form &it
&it /div &it
&it /body &it
&it /html &it



The body refers to a PHP file which I have included below, though I'm not experienced enough to know if this would have any effect on the problem (I don't know PHP as yet)


&it html &it
&it body &it
&it ?php
$num = rand(1000, 10000);
$name = $_POST['name'];
$minutes = $_POST['pickupminutes'];
$total = $_POST['total'];

echo "&it h1 &it Duncan's Just-In-Time Donuts &it /h1 &it";
echo "&it h2 &it Order Confirmation &it /h2 &it";
echo "&it strong &it Order #" . $num . "&it /strong&it &it br / &it";
echo "Customer name: " . $name . "&it br / &it";
echo "Ready in: " . $minutes . " minutes &it br / &it";
echo "Total: &it em &it" . $total . "&it /em &it";
? &it
&it /body &it
&it /html &it



I'm apologise for not explaining this well but I am really new to javascript and find some of the terms confusing at this point.
So you are saying that my encoding of the page and my javascript are good, so why am I still displaying the unwanted � character?
Hi, Thanks for your reply. The DOCTYPE, meta and link are as below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/DTD/xhtml1/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Duncan's Just-In-Time Donuts</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="donuts.css" />

However I'm still producing the special character � before the � sign in my file!
Sorry ignore the comment re script in bold as it's not been shown in bold, It's this bit:

document.getElementById("subtotal").value = "�" + subTotal.toFixed(2);
document.getElementById("tax").value = "�" + tax.toFixed(2);
document.getElementById("total").value = "�" + total.toFixed(2);
Hi. I am a newbie to javascript so please excuse me if my question is obvious, but I just can't seem to solve it. I am working through the book 'Head First JavaScipt' by M Morrison and was working on a scipt called Duncan's Just-In-Time Donuts. The currency was set to dollars and I wanted to change it to pounds sterling. This is the script:



I have changed the $ signs to � (the section of Code is shown in bold), but when I run the script the � sign is preceded by a special character like so:-
��
my question is how do I eliminate the unwanted � sign?

I am using a Intel Mac pro using Leopard O/S and my browsers are Safari (default) and FireFox. I also have Opera but have not as yet run this script on it.

I hope you can help me with this as I live in the UK and will need to be able to use the � for currency in the majority of my scripts.

Regards denis