首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

高分求字段其间求和,计算的代码

2011-11-07 
高分求字段之间求和,计算的代码SCRIPTlanguageJavaScript!--functiontotalAccount(){document.form1.N

高分求字段之间求和,计算的代码
<SCRIPT   language=JavaScript>
<!--

function   totalAccount()
{
document.form1.NumB.value   =   parseInt(document.form1.ItemPrice.value)*parseInt(document.form1.Times.value);
document.form1.NumB.value   =   stringOper(document.form1.NumB.value);
}
function   stringOper(str)
{
        var   length       =   str.length;
var   position   =   str.indexOf( ". ");
var   cha   =   length-position;
if(position   ==   -1)
{
str   =   str+ ".00 ";
}
else   if(cha   ==   1)
{
str   =   str+ "00 ";
}
else   if(cha   ==   2)
{
str   =   str+ "0 ";
}
else   if(cha   >   3)
{
str   =   str.substr(0,(length-(cha-3)));
}
else
{
str   =   str;
}
return   str;
}

//-->
</SCRIPT>
<table   width= "100% "   border= "1 "   cellpadding= "0 "   cellspacing= "0 "   id=t   bordercolorlight= "#808080 "   bordercolordark= "#FFFFFF "   class= "black ">  
    <tr   align= "center "   bgcolor= "#D4D0C8 "   class= "black "   >
        <td   width= "5% "   height= "20 "> 序号 </td>
        <td   width= "13% "> 类别 </td>
        <td   width= "44% "> 项目名称 </td>
        <td   width= "12% "> 单价 </td>
        <td   width= "11% "> 数量 </td>
        <td   width= "10% "> 金额 </td>
        <td   width= "5% "> 删除 </td>
    </tr>
<%   if   (flag   !=   null   &&   flag.equals( "1 "))
{
List     PriceList   =QuotationMng.getresLinePrice(request.getParameter( "line "));
priceListLength   =   PriceList.size();
ResLinePrice   Price;
for(int   i=0;i <5;i++)
{
        if(i <PriceList.size())
{
Price   =   (ResLinePrice)PriceList.get(i);
}
else
{
Price   =   new   ResLinePrice();
}

%>
    <tr   bgcolor= "#FFFFFF ">  
        <td   align= "center ">   <strong> <%=(i+1)%> &nbsp; </strong> </td>
        <td   align= "center "> <input   name= "ItemName "   type= "text "   id= "ItemName1 <%=(i+1)%> "   value= " <%=((Price.getItemName()==null)? " ":Price.getItemName())%> "> </td>
        <td   align= "center "> <input   name= "ItemContent "   type= "text "   id= "ItemContent1 <%=(i+1)%> "   value= " <%=((Price.getItemContent()==null)? " ":Price.getItemContent())%> "   style= "width:95% "> </td>


        <td   align= "center "> <input   name= "ItemPrice "   type= "text "   id= "ItemPrice <%=(i+1)%> "   value= " <%=((Price.getItemPrice()==null)? " ":Price.getItemPrice())%> "   size= "10 "> </td>
        <td   align= "center "> <input   name= "Times "   type= "text "   id= "Times <%=(i+1)%> "       size= "10 "   value= "0 "> </td>
        <td   align= "center "> <input   name= "NumB "   type= "text "   id= "NumB <%=(i+1)%> "     value= "0 "   size= "6 "   onFocus= "totalAccount() "> </td>
        <td   align= "center "> <input   type=checkbox     name=c> </td>
    </tr>
<%
}
}
%>
    <tr   align= "right "   bgcolor= "#FFFFFF ">  
        <td   colspan= "7 "> <input       type=button       value= "del "       onclick= "del() ">   合计:负零元零角零分   ¥.00 </strong>   </td>
    </tr> </table>
////////
谁能告诉我为什么不能计算出结果呢?在线等

[解决办法]
你的form1在哪儿呢?
[解决办法]
对不起,因为代码太多,我取了中间的,您看到的代码就是在form1中的
[解决办法]
在js里面多写点alert(),调试一下.
[解决办法]
js里有eval函数可以用来求职的

热点排行