您的位置首页生活小窍门

跪求 JS中金额大小写转换 且四舍五来自入保留两位小数

问题补充说明:如我输入100.999后应该显示101.00,对应大写也是壹百零壹元整。各位大神 如果采纳后继续追加10分!!

跪求 JS中金额大小写转换 且四舍五来自入保留两位小数

<scripttype="text/javascript">

functionmoney(mon){

varsmon=Math.round(mon*100);

varsplot=smon%100;

varzheng=parseInt(smon/100);

varch_key=newArray('零','壹','贰','叁','肆','伍','陆','柒','捌','玫');

vardan_k但道领策ey=newAr儿型试儿请今左ray('拾','佰','仟','万','拾万','百万','仟万','亿');

varstr_num米尼越项记=zheng+'';

期行银varlen=str_num.length;

varslen=len-1;

varrs=''

for(var路化i=0;i<len;从责春培i++){

varch=parseInt(str_num.charAt(i));

rs+=ch_key[ch];

slen--;

if(ch>0&&slen>=0)rs+=dan_key[slen];

}

if(splot==0){

rs+='元整';

长氧尔末兵原织饭冲策}else{

varstr=splot+'';

varch=parseInt(str.charAt(0));

rs+='点'+ch_key[ch];

ch=parseInt(str.charAt(1));

rs+=ch_ke副务绍根银为问y[ch]+'元';

}

returnrs;

}

alert(money(211199.999));

</script>