JS显示问题 急!!! 要实现这样是个财务数的展示问题例如输入框中有33333,显示为33,333当输入金额的时候,也自动每三个进行分割,还有就是如果直接赋值 例如从数据库查出个数,显示为每三个用,分割 怎么分割 谢谢啦 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>aaa</title></head><body><input id='ss' type="text" onfocus="this.value=this.value.replace(/\,+/g,'');this.select()" onblur="formatnum(this,this.value)" value='1223123123'><script type="text/javascript">window.onload = function(){ var ss =document.getElementById('ss'); formatnum.call(ss,ss,ss.value); //直接赋直就调用下}function formatnum(o,s){ o.value = s.replace(/[^\d]+/g,'').replace(reg1,'$1,')}</script></body></html> 上面的正则写掉了 无视吧<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>eee</title></head><body><input id='ss' type="text" onfocus="this.value=this.value.replace(/\,+/g,'');this.select()" onblur="formatnum(this,this.value)" value='12123123123'><script type="text/javascript">window.onload = function(){ var ss =document.getElementById('ss'); formatnum.call(ss,ss,ss.value);}function formatnum(o,s){ o.value = s.replace(/[^\d]+/g,'').replace(/(\d{1,3})(?=(\d{3})+$)/g,'$1,')}</script></body></html> var n = 66666.4;alert(n.toLocaleString()); 不好意思 可能之前我说的不够明白,在HTML的文本框内,显示用“ ,”分割的金额,也就是千分位显示(例如29,897.00元),当点击文本框,每输入一个数字,就自动按照千分位排列, 特殊的情况是当这个数不是整数,有小数位的时候,这个小数点后面的是不需要千分位显示,有几位小数就几位小数,麻烦哪位大侠给做个例子啊 用ASP.net 前台用一个JS方法,后台在做一个,因为有时候这个数我需要从数据库查出来赋值 急急急!!!!!!! var n = 66666.4;alert(n.toLocaleString()); toLocaleString : StringReturns a string representing the number that follows local formatting conventions.Supported: IE 5.5+, Mozilla 1.0+, Netscape 6.0+, Opera 7.0+, Safari 1.0+ js怎么将字段+数值以XML形式返回给webservice js 弹出层 ASp.net中javascript的问题 javascript 如何控制excel生成chart图? 我是新手,请各位大侠帮忙,我想做个跟这个社区一样的左边菜单。请问怎么做? 菜鸟小问题求助,谢谢 页面中鼠标指针图形的问题,求指导 如何在选择下拉列表框时动态改变另一个列表框的数据(读数据库,不能刷新页面) 求一段jquery代码,解决方格抽奖问题 请教一下这样用&&怎么理解 散分 js里判断出来之后能执行alert却不执行别的,大家来帮帮忙
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>aaa</title></head>
<body>
<input id='ss' type="text" onfocus="this.value=this.value.replace(/\,+/g,'');this.select()" onblur="formatnum(this,this.value)" value='1223123123'>
<script type="text/javascript">
window.onload = function(){
var ss =document.getElementById('ss');
formatnum.call(ss,ss,ss.value); //直接赋直就调用下
}
function formatnum(o,s){
o.value = s.replace(/[^\d]+/g,'').replace(reg1,'$1,')
}
</script></body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>eee</title></head>
<body>
<input id='ss' type="text" onfocus="this.value=this.value.replace(/\,+/g,'');this.select()" onblur="formatnum(this,this.value)" value='12123123123'>
<script type="text/javascript">
window.onload = function(){
var ss =document.getElementById('ss');
formatnum.call(ss,ss,ss.value);
}
function formatnum(o,s){
o.value = s.replace(/[^\d]+/g,'').replace(/(\d{1,3})(?=(\d{3})+$)/g,'$1,')
}</script></body>
</html>
var n = 66666.4;
alert(n.toLocaleString());
alert(n.toLocaleString());
Returns a string representing the number that follows local formatting conventions.
Supported: IE 5.5+, Mozilla 1.0+, Netscape 6.0+, Opera 7.0+, Safari 1.0+