javascript 动态生成值

今天在修改代码过程中,对于jsp脚本动态加载行,如何根据某个input的值生成另一个td中的值
<%
  
        NumberFormat numberFormat = NumberFormat.getNumberInstance();
        numberFormat.setMaximumFractionDigits(4);
      
          
       for(int i=0;i<v.size();i++)
       {
            BinZB bin=(BinZB)v.get(i);

            String slaveEmpno = bin.getSlaveEmpno();
            String slaveName  = bin.getSlaveName();
            String jibie      = bin.getJibie();
            if(jibie!=null){
               jibie = jibie.trim();
             }
            String d01        = bin.getd0();
            String stu        = "否";   
            if(d01==null)
            {
              d01="0";
            }
            float  d02=Float.parseFloat(d01);
            if(d02<0){
              out.print("D0<0,逻辑错误。");
              return;
            }
            if(d02<7||(d02==100||d02==1000)){
            String Qi         = bin.getQi();
            //out.print("**"+Qi);
            if(Qi==null){
             // Qi="领导还没有打分";
             Qi="0";
              //continue;
            }
            if(countJiDu>0&!jidukaohe){
              Qi="101";
            }
           // out.print("%%"+Qi);
             //Qi/Q平均* Z平均=Zi
            float Zi=0; 
            float Bi=0;
            String student=bin.getStudent();
            
            if(jibie.equals("G")||jibie.equals("g")||jibie.equals("E")||jibie.equals("e")||jibie.equals("f")
  ||jibie.equals("F")||jibie.equals("D")||jibie.equals("d")||jibie.equals("C")||jibie.equals("c")
  ||jibie.equals("B")||jibie.equals("b")||jibie.equals("A")||jibie.equals("a"))
            {
              if(student.equals("0"))//老员工
              {                
                 if(pjQiG==0){
                   Zi=0;
                 }
                 else{
                   Zi=Float.parseFloat(Qi)/pjQiG*pjzG;
                 }             
                  //out.print("ss"+pjQiG);               
                 if(Qi.equals("0")){
                   Bi=0;
                 }
                 else{
                   Bi=Float.parseFloat(Qi)/pjQiG2*PJjixiaoG;  
                 }
                 stu="否";     
                 //out.print(xishuOld);    
                                                    
              }
              else//应届生
              { 
                 if(Qi.equals("0")){
                   Bi=0;
                 }else{
                     if(pjQiNew==0){
                      Zi=0;
                     }
                     else{
                      Zi=Float.parseFloat(Qi)/pjQiNew*pjzNew;
                     }          
                    Bi=Float.parseFloat(Qi)/pjQiNew2*PJjixiaoNew;
                    //out.print("__"+pjQiNew2+"<br>");//==========================               
                  }
                 stu="是";
              } 
            }            
             if(jibie.equals("H")||jibie.equals("h")){
               
                if(Qi.equals("0"))
                 {
                   Bi=0;
                 }else
                 {
                if(pjQiH==0){
                   Zi=0;
                }else{
                   Zi=Float.parseFloat(Qi)/pjQiH*pjzH;
                }                   
                 Bi=Float.parseFloat(Qi)/pjQiH2*PJjixiaoH;
                 }
             }
           
           //季度考核数据过滤
           if(Qi.equals("101")){
                   Qi="";
                   Zi=0;
                 
                 }
                                                  
             
  //若d0=100 or d0=1000,则Bi=0           
             if(Float.parseFloat(d01)==100||Float.parseFloat(d01)==1000)//100 or 1000没有绩效
             {
                 Bi=0;
                 //out.print(slaveName);
             }
          
            if(flag.equals("1000")){
             //System.out.println("user:"+userEmpno+"slave:"+slaveEmpno);
               if(!userEmpno2.equals(slaveEmpno.trim()))
               continue;
            }
            
   %>
    <tr>
      <td width="82" height="22" align="center"><%=slaveName%></td>
      <td  width="100" height="22" align="center"><%=slaveEmpno%></td>
      <td  width="69"  height="22" align="center"><%=jibie%></td>
      <td  width="89"  height="22" align="center"><%=stu%></td>
      <td  width="108" height="22" align="center"><%=d01 %></td>
      <td  width="101" height="22" align="center"><%=Qi %></td>
      <td  width="113"  height="22" align="center"><%=numberFormat.format(Zi) %></td>
      <%if(!(flag.equals("1000")||flag.equals("999"))) {%>
      <td  height="22" align="center"><%=numberFormat.format(Bi) %></td>
      <%} else{%>
      <td  height="22" align="center"></td>
      <%} %>
      <%if(flagMaster) {%>
      <td height="22" align="center"><input id="plusB" name="plusB" style="width:38" type="text" onchange="add(this)"/></td>
      <td width="101" height="22" align="center"></td>
      <%} %>
    </tr>

function add(src) {
	      document.getElementById('tab').rows[src.parentNode.parentNode.rowIndex].cells[9].innerHTML = parseFloat(src.value) + parseFloat(document.getElementById('tab').rows[src.parentNode.parentNode.rowIndex].cells[7].innerHTML);
     }

用alert找到src.parentNode.parentNode才是row对象,而rc.parentNode只是cell对象!

你可能感兴趣的:(JavaScript,C++,c,jsp,脚本)