怎样修改资金余额小数位数_动易Cms教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

问题:怎样修改资金余额小数位数
解决:后台管理 >> 系统设置 >> 模板标签管理 >> 标签管理,找到并修改标签“Ajax用户登录”,找到下面段代码

function GetUserInfo(xml)
{
var userInfo="<div class=\"u_login\">" xml.getElementsByTagName("username")[0].firstChild.data ",您好!您有:<br/>";
userInfo =userInfo "资金余额:" xml.getElementsByTagName("balance")[0].firstChild.data " 元<br/>";
userInfo =userInfo "经验积分:" xml.getElementsByTagName("exp")[0].firstChild.data " 分<br/>";
userInfo =userInfo "待阅短信:" xml.getElementsByTagName("msg")[0].firstChild.data " 条<br/>";
userInfo =userInfo "登录次数:" xml.getElementsByTagName("logintimes")[0].firstChild.data " 次<br/>";
userInfo =userInfo "可用点券:" xml.getElementsByTagName("point")[0].firstChild.data " " xml.getElementsByTagName("pointunit")[0].firstChild.data "<br/>";
userInfo =userInfo "待签文章:" xml.getElementsByTagName("signincontent")[0].firstChild.data " 篇<br/>";
userInfo =userInfo "<div style=\"text-align: center\"><a href=\"{PE.SiteConfig.ApplicationPath /}User/Default.aspx\" target=\"_top\">会员中心</a>&nbsp;&nbsp;|&nbsp;&nbsp;";
userInfo =userInfo "<a href=\"{PE.SiteConfig.ApplicationPath /}User/Logout.aspx\" target=\"_top\">退出登录</a></div>";
userInfo=userInfo "</div>";
return userInfo;
}


改为:

function GetUserInfo(xml)
{
var userInfo="<div class=\"u_login\">" xml.getElementsByTagName("username")[0].firstChild.data ",您好!您有:<br/>";
userInfo =userInfo "资金余额:" xml.getElementsByTagName("balance")[0].firstChild.data " 元<br/>";
userInfo =userInfo "资金余额:" round(xml.getElementsByTagName("balance")[0].firstChild.data,2) " 元<br/>";
userInfo =userInfo "经验积分:" xml.getElementsByTagName("exp")[0].firstChild.data " 分<br/>";
userInfo =userInfo "待阅短信:" xml.getElementsByTagName("msg")[0].firstChild.data " 条<br/>";
userInfo =userInfo "登录次数:" xml.getElementsByTagName("logintimes")[0].firstChild.data " 次<br/>";
userInfo =userInfo "可用点券:" xml.getElementsByTagName("point")[0].firstChild.data " " xml.getElementsByTagName("pointunit")[0].firstChild.data "<br/>";
userInfo =userInfo "待签文章:" xml.getElementsByTagName("signincontent")[0].firstChild.data " 篇<br/>";
userInfo =userInfo "<div style=\"text-align: center\"><a href=\"{PE.SiteConfig.ApplicationPath /}User/Default.aspx\" target=\"_top\">会员中心</a>&nbsp;&nbsp;|&nbsp;&nbsp;";
userInfo =userInfo "<a href=\"{PE.SiteConfig.ApplicationPath /}User/Logout.aspx\" target=\"_top\">退出登录</a></div>";
userInfo=userInfo "</div>";
return userInfo;
}
function round(v,e)
{
var t=1;
for(;e>0;t*=10,e--);
for(;e<0;t/=10,e );
return Math.round(v*t)/t;
}

修改下面的“2”,可以实现位数控制,0为无小数位,1为一位小数,2为二位小数,3为三位小数。

userInfo =userInfo "资金余额:" round(xml.getElementsByTagName("balance")[0].firstChild.data,2) " 元<br/>";

查看更多 动易Cms教程  动易Cms模板

来源:模板无忧//所属分类:动易Cms教程/更新时间:2009-04-02
相关动易Cms教程