我想打印这个脚本货币格式千位分隔符用逗号或点javascript。
我的意思是,例如我会打印1.001,00而不是1001
我应该为此脚本添加哪些代码?
<script type="text/javascript" src="//code.jquery.com/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(window).load(function(){
$('input').change(function(){
var linetotals = 0;
$('[name^="price"]').each(function(){
price = $(this).parents('tr').find('input').eq(0).val();
quantity = $(this).parents('tr').find('input').eq(1).val();
$(this).val(price*quantity);
linetotals += price*quantity;
});
$('[name=subtotal]').val(linetotals);
});
});
</script>
&#13;
<form name="invoice form" action="saveToDatabase.java">
<table width="30%" border="1" height="30%">
<tbody>
<tr>
<td colspan="5" align="center">Customer Invoice</td>
</tr>
<tr>
<td width="5%" bgcolor="#CCCCCC">Sn.no.</td>
<td width="25%" bgcolor="#CCCCCC">Item</td>
<td width="25%" bgcolor="#CCCCCC">Unit Price(In $)</td>
<td width="20%" bgcolor="#CCCCCC">Quantity</td>
<td width="25%" bgcolor="#CCCCCC">Line Total<br>(Price * Qnty)</td>
</tr>
<tr>
<td width="5%">1</td>
<td width="25%">Iphone 5S</td>
<td width="25%"><input value="400" name="unitprice1" size="4" type="text"></td>
<td width="20%"><input name="quantity1" value="2" size="2" type="text"></td>
<td width="25%"><input name="price1" value="400" size="4" type="text"></td>
</tr>
<tr>
<td width="5%">2</td>
<td width="25%">Ipad 2</td>
<td width="25%"><input value="700" name="unitprice2" size="4" disabled="" type="text"></td>
<td width="20%"><input name="quantity2" value="1" size="2" type="text"></td>
<td width="25%"><input name="price2=" value="700" size="4" type="text"></td>
</tr>
<tr>
<td width="5%">1</td>
<td width="25%">mp3</td>
<td width="25%"><input value="50" name="unitprice1" size="4" disabled="" type="text"></td>
<td width="20%"><input name="quantity1" value="3" size="2" type="text"></td>
<td width="25%"><input name="price1" value="150" size="4" type="text"></td>
</tr>
<tr>
<td colspan="5" align="right">Total<input name="subtotal" value="1250" size="12" disabled="" type="text"></td>
</tr>
</tbody>
</table>
</form>