Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript Currency Formatting

Status
Not open for further replies.

columbo1977

Programmer
May 9, 2006
49
GB
Hi there

I was wondering if anyone could help me, I have an order form that has a quantity and cost fields and a total at the bottom i was wondering if anyone would know how to apply formatting to the cost fields and the total field so they can appear as currency.

Please see the code below.

Columbo1977

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><!-- InstanceBegin template="/Templates/Template_new.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<script type="text/javascript">
<!--
function checkCost()
{
var counter=0;
var grandtotal=0;
for (var i=0; i<document.shop_cart.length; i++)
{
if (document.shop_cart.name=="cost[]")
{
unitprice = (document.shop_cart[i-2].value);
quantity = (document.shop_cart[i-1].value);
document.shop_cart.value = unitprice * quantity;
grandtotal += parseFloat(document.shop_cart.value);
}
}
document.shop_cart.grandtotal.value = grandtotal;
}
-->

</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Gagets Galore</title>
<!-- InstanceEndEditable -->
<link rel="stylesheet" type="text/css" href="style.css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body bgcolor="#933FC0" link="#0000FF" vlink="#0000FF" alink="#0000FF" onload="checkCost();">
<form name="shop_cart" action="your_action_form" method="post">
<table width="100%" height="515" border="0" cellpadding="1">
<tr>
<td valign="top"><table width="100%" height="78" border="0" cellpadding="1">
<tr>
<td><div align="center"><img src="images/banner.jpg" width="800" height="50"></div></td>
</tr>
</table>
<table width="100%" height="487" border="0" cellpadding="1">
<tr>
<td width="87%" valign="top"><table width="100%" border="0" cellpadding="1" id="links">
<tr>
<td><table width="100%" border="0" cellpadding="1">
<tr>
<td width="15%"><div align="center"><a href="index.html">Home</a></div></td>
<td width="15%"><div align="center"><a href="products.html">Products</a></div></td>
<td width="15%"><div align="center"><a href="order.html">Order
Form </a></div></td>
<td width="15%"><div align="center"><a href="shopping.html">Shopping
Basket </a></div></td>
<td width="15%"><div align="center"><a href="contact.html">Contact
Us </a></div></td>
<td width="15%"><div align="center"><a href="links.html">Links</a></div></td>
</tr>
</table></td>
</tr>
</table>
<!-- InstanceBeginEditable name="main" -->
<table width="100%" height="456" border="0" cellpadding="1">
<tr>
<td valign="top"><table width="100%" height="453" border="0" cellpadding="1">
<tr id="title">
<td height="45"><div align="center">Toys Order Form</div></td>
</tr>
<tr id="main">
<td valign="top"><div align="center">
<table width="60%" border="0">
<tr>
<th width="18%">Product Id</th>
<th width="20%">Product Name</th>
<th width="19%">VAT-exclusive retail price</th>
<th width="21%">Quantity</th>
<th width="22%">Cost(&pound;)</th>
</tr>
</table>
</div>
<div style="height: 300px; overflow: auto;" align="center">

<table width="60%" border="0">
<tr>
<td width="20%"><div align="center">ZWS019</div></td>
<td width="20%"><div align="center">House</div></td>
<td width="20%"><div align="center">169.73</div></td>
<td width="20%"><input type="text" maxlength="3" name="quantity[]" value="" onkeyup="checkCost();"></td><input type="hidden" name="unitprice[]" value="169.73">
<td width="20%"><input type="text" name="cost[]" value="" readonly onBlur=""></td>
</tr>
<tr>
<td><div align="center">ZWS026</div></td>
<td><div align="center">Aeroplane</div></td>
<td><div align="center">171.43</div></td>
<td><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="171.43">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS034</div></td>
<td><div align="center">Car</div></td>
<td><div align="center">54.36</div></td>
<td><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="54.36">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS036</div></td>
<td><div align="center">Lorry</div></td>
<td><div align="center">182.76</div></td>
<td><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="182.76">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS037</div></td>
<td><div align="center">Doll</div></td>
<td><div align="center">150.95</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="150.95">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS047</div></td>
<td><div align="center">Soldier</div></td>
<td><div align="center">154.12</div></td>
<td><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="154.12">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td height="29"><div align="center">ZWS051</div></td>
<td><div align="center">Dog</div></td>
<td><div align="center">95.43</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="95.43">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS053</div></td>
<td><div align="center">Cat</div></td>
<td><div align="center">162.42</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="162.42">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS062</div></td>
<td><div align="center">Elephant</div></td>
<td><div align="center">71.34</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="71.34">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS064</div></td>
<td><div align="center">Town</div></td>
<td><div align="center">61.35</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="61.35">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS072</div></td>
<td><div align="center">Rifle</div></td>
<td><div align="center">27.51</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="27.51">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS079</div></td>
<td><div align="center">Pistol</div></td>
<td><div align="center">131.89</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="131.89">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS082</div></td>
<td><div align="center">Helmet</div></td>
<td><div align="center">151.23</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="151.23">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS088</div></td>
<td><div align="center">Spaceship</div></td>
<td><div align="center">31.99</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="31.99">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS094</div></td>
<td><div align="center">Ship</div></td>
<td><div align="center">100.55</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="100.55">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS101</div></td>
<td><div align="center">Tree</div></td>
<td><div align="center">40.68</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="40.68">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS104</div></td>
<td><div align="center">Hovercraft</div></td>
<td><div align="center">51.19</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="51.19">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS113</div></td>
<td><div align="center">Glider</div></td>
<td><div align="center">164.74</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="164.74">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS116</div></td>
<td><div align="center">Telescope</div></td>
<td><div align="center">155.55</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="155.55">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS124</div></td>
<td><div align="center">Binoculars</div></td>
<td><div align="center">183.79</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="183.79">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS128</div></td>
<td><div align="center">Monkey</div></td>
<td><div align="center">98.28</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="98.28">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS131</div></td>
<td><div align="center">Dinosaur</div></td>
<td><div align="center">177.23</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="177.23">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS140</div></td>
<td><div align="center">Helicopter</div></td>
<td><div align="center">139.81</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="139.81">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS145</div></td>
<td><div align="center">Horse</div></td>
<td><div align="center">199.65</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="199.65">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS155</div></td>
<td><div align="center">Stethoscope</div></td>
<td><div align="center">57.07</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="57.07">
<td><input name="cost[]" type="text" id="cost[]" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS161</div></td>
<td><div align="center">Motorbike</div></td>
<td><div align="center">33</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value=".33">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS167</div></td>
<td><div align="center">Tricycle</div></td>
<td><div align="center">186.59</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="186.59">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS168</div></td>
<td><div align="center">Hospital</div></td>
<td><div align="center">130.01</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="130.01">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS169</div></td>
<td><div align="center">Cooker</div></td>
<td><div align="center">20.51</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onKeyUp="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="20.51">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS176</div></td>
<td><div align="center">Battle</div></td>
<td><div align="center">153.62</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="153.62">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS180</div></td>
<td><div align="center">Radio</div></td>
<td><div align="center">98.79</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="98.79">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS183</div></td>
<td><div align="center">Television</div></td>
<td><div align="center">104.1</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="104.1">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS191</div></td>
<td><div align="center">Computer</div></td>
<td><div align="center">120.57</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="120.57">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS192</div></td>
<td><div align="center">Acrobat</div></td>
<td><div align="center">64.37</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="64.37">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS193</div></td>
<td><div align="center">Juggler</div></td>
<td><div align="center">155.76</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="155.76">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS194</div></td>
<td><div align="center">Fire Station</div></td>
<td><div align="center">179.51</div></td>
<td nowrap><input name="quantity[]" type="text" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="179.51">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS199</div></td>
<td><div align="center">Tank</div></td>
<td><div align="center">119.36</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="119.36">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS202</div></td>
<td><div align="center">Butterfly</div></td>
<td><div align="center">50.79</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="50.79">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS205</div></td>
<td><div align="center">Alarm Clock</div></td>
<td><div align="center">108.69</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="108.69">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS206</div></td>
<td><div align="center">Angel</div></td>
<td><div align="center">63.76</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="63.76">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS207</div></td>
<td><div align="center">Bicycle</div></td>
<td><div align="center">133.86</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="133.86">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS213</div></td>
<td><div align="center">Boat</div></td>
<td><div align="center">133.96</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="133.96">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS215</div></td>
<td><div align="center">Brooch</div></td>
<td><div align="center">88.2</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="88.2">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWtestS216</div></td>
<td><div align="center">Bunker</div></td>
<td><div align="center">252.82</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="252.82">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS218</div></td>
<td><div align="center">Butcher's Shop</div></td>
<td><div align="center">128.91</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="128.91">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS223</div></td>
<td><div align="center">Filing Cabinet</div></td>
<td><div align="center">198.06</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="198.06">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS232</div></td>
<td><div align="center">Camp Site</div></td>
<td><div align="center">122.82</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="122.82">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS238</div></td>
<td><div align="center">Cannon</div></td>
<td><div align="center">6.76</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="6.76">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS245</div></td>
<td><div align="center">Caravan</div></td>
<td><div align="center">151.8</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="151.8">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS251</div></td>
<td><div align="center">Carpet</div></td>
<td><div align="center">81.21</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="81.21">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS254</div></td>
<td><div align="center">Castanets</div></td>
<td><div align="center">37.12</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="37.12">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS255</div></td>
<td><div align="center">Castle</div></td>
<td><div align="center">152.95</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="152.95">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS264</div></td>
<td><div align="center">Catapult</div></td>
<td><div align="center">25.62</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="25.62">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS267</div></td>
<td><div align="center">Circus</div></td>
<td><div align="center">62.16</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="62.16">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS272</div></td>
<td><div align="center">Cockroach</div></td>
<td><div align="center">188.06</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="188.06">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS280</div></td>
<td><div align="center">Crane</div></td>
<td><div align="center">188.93</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="188.93">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS290</div></td>
<td><div align="center">Dagger</div></td>
<td><div align="center">25.42</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="25.42">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS296</div></td>
<td><div align="center">Chopsticks</div></td>
<td><div align="center">71</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value=".71">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS305</div></td>
<td><div align="center">Sword</div></td>
<td><div align="center">92.45</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="92.45">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS311</div></td>
<td><div align="center">Spear</div></td>
<td><div align="center">173.77</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="173.77">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS319</div></td>
<td><div align="center">Tape Recorder</div></td>
<td><div align="center">54.82</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="54.82">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS320</div></td>
<td><div align="center">Monster</div></td>
<td><div align="center">72.08</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="72.08">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS328</div></td>
<td><div align="center">Lawn Mower</div></td>
<td><div align="center">27.36</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="27.36">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS338</div></td>
<td><div align="center">Javelin</div></td>
<td><div align="center">163.33</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="163.33">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS348</div></td>
<td><div align="center">Drum</div></td>
<td><div align="center">33.5</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="33.5">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS355</div></td>
<td><div align="center">Trumpet</div></td>
<td><div align="center">103.64</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="103.64">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS356</div></td>
<td><div align="center">Comb</div></td>
<td><div align="center">54</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value=".54">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS362</div></td>
<td><div align="center">Harmonica</div></td>
<td><div align="center">130.81</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="130.81">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS366</div></td>
<td><div align="center">Jigsaw</div></td>
<td><div align="center">16.03</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="16.03">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS368</div></td>
<td><div align="center">Marbles</div></td>
<td><div align="center">9.18</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="9.18">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
<tr>
<td><div align="center">ZWS375</div></td>
<td><div align="center">Puzzle</div></td>
<td><div align="center">21.73</div></td>
<td nowrap><input name="quantity[]" type="text" maxlength="3" id="quantity[]" onkeyup="checkCost();" value=""></td><input type="hidden" name="unitprice[]" value="21.73">
<td><input name="cost[]" type="text" id="cost[]" value="" readonly></td>
</tr>
</table>

</div>
<div align="center">
<table width="60%" border="0" cellpadding="0">
<tr>
<td><div align="right">Total Cost Exc VAT</div></td>
<td width="20%"><div align="right">
<input type="text" name="grandtotal" value="" readonly>
</div></td>
<td width="3%"></td>
</tr>
<tr>
<td><div align="right">VAT</div></td>
<td width="20%"><div align="right"></div></td>
</tr>
<tr>
<td><div align="right">Total Cost Inc VAT</div></td>
<td>&nbsp;</td>
</tr>
</table>
</div>
<p>&nbsp;</p>
</td>
</tr>
</table></td>
</tr>
</table>
<!-- InstanceEndEditable --></td>
</tr>
</table> </td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
 
The first thing you should do is sort out your IDs.

Not only do they contain illegal characters ("[" and "]"), but they are not unique, either - so breaking the specs on two counts. Your names that contain "[" and "]" are also illegal, so you should resolve that, too.

W3C said:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

To answer your question... can you further define what you mean by "so they appear as currency"? You could say that by simply placing a "£" or "$" in front of the field, it now appears as a currency... but I can't believe you wouldn't have thought of that, so assume you have some other requirement you've not mentioned?

Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I have tried putting a pound sign in fron t of thema nd it will not appear, I just need them to appear as currency, and I also need them fromatted to 2 decimal places.

i am new to javascript and some of the code was got from freescripts.

thanks for your help so far.

Columbo1977
 
Columbo1977 - I wonder if maybe some of your original post was truncated?

In future, post code between [ignore]
Code:
your code here
[/ignore] and whittle down your code to show the relevant code for your problem (I mean... do we REALLY need to see 50 rows containing the same kind of information when 2 or 3 rows would have been fine?).

If you are doing some math on those costs/totals using javascript, then you would need to write a function to manage the .00 part.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
sorry about that I dodnt know I thought people would want to see all of the code to get an iddea of what i needed.

and as I am new i dont know what to write for the function or where to call it.

Columbo1977
 
I have tried putting a pound sign in fron t of thema nd it will not appear

That's odd - it should appear just fine, assuming you're inserting it correctly. You should use the HTML character entity "&pound;" rather than the pound sign (£), of course.

Perhaps you can show us where / how you are inserting it?

As to formatting to 2dp, you can use the "toFixed" method:

Code:
alert(123.5.toFixed(2)); // should alert 123.50

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top