我是靠谱客的博主 彪壮期待,最近开发中收集的这篇文章主要介绍javascript eval函数的应用,循环合并表格内容,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>eval函数的应用,循环合并表格内容</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<script language="JavaScript" type="text/javascript">

function calprice() {
var sss="";
 for(i = 0; i < 10 ; i++) {
  var str="";
  var strr = eval(document.getElementById('Date'+i)).innerHTML+": ";
   for(n = 0; n < 3; n++) {
    if(eval("document.form.num"+i)[n].value != "") {
     alert("num"+i+"["+n+"]"+eval("document.form.num"+i)[n].value);//测试
     
     switch(n) {
     case 0:
      str += "[ A+ ][ " + eval("document.form.num"+i)[n].value + " ]"
        +"Price[ " + eval(document.getElementById('prAp'+i)).innerHTML + " ], ";
      break;
     case 1:
      str += "[ A ][ " + eval("document.form.num"+i)[n].value + " ]"
        +"Price[ " + eval(document.getElementById('prA'+i)).innerHTML + " ], ";
      break;
     case 2:
      str += "[ B ][ " + eval("document.form.num"+i)[n].value + " ]"
        +"Price[ " + eval(document.getElementById('prB'+i)).innerHTML + " ], ";
      break;
     } 
    }
   }
  if(str!="") {
   strr += str;
   strr = strr.substring(0,strr.lastIndexOf(','))+".";
   sss+=strr+"/n";
  }
 }
 sss = sss.substring(0,sss.lastIndexOf('/n'));
 if(sss!="") {
  alert(sss);
 }
}
</script>

<body>
 <form name="form" id="fp" action="account"
                  <table width="660" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#E3E3E3">
                    <tr>
                      <td rowspan="2" align="center" bgcolor="#C80000"><font color="#FFFFFF"><strong>行数</strong></font></td>
                      <td colspan="6" align="center" bgcolor="#C80000"><font color="#FFFFFF"><strong>数值</strong></font></td>
                    </tr>
                    <tr>
                      <td align="center" bgcolor="#C80000"><font color="#FFFFFF"><strong>类型A+</strong></font></td>
                      <td align="center" bgcolor="#C80000"><font color="#FFFFFF"><strong>数量</strong></font></td>
                      <td align="center" bgcolor="#C80000"><font color="#FFFFFF"><strong>类型A</strong></font></td>
                      <td align="center" bgcolor="#C80000"><font color="#FFFFFF"><strong>数量</strong></font></td>
                      <td align="center" bgcolor="#C80000"><font color="#FFFFFF"><strong>类型B</strong></font></td>
                      <td align="center" bgcolor="#C80000"><font color="#FFFFFF"><strong>数量</strong></font></td>
                    </tr>
                    <tr>
                      <td align="left" bgcolor="#F0F0F0" id="Date0">第一行</td>
                      <td align="center" bgcolor="#F0F0F0" id="prAp0">00</td>
                      <td align="center" bgcolor="#F0F0F0"><input name="num0" id="fp_inum00" type="text" size="5" alt="_int_"></td>
                      <td align="center" bgcolor="#F0F0F0" id="prA0">01</td>
                      <td align="center" bgcolor="#F0F0F0"><input name="num0" id="fp_inum01" type="text" size="5" alt="_int_"></td>
                      <td align="center" bgcolor="#F0F0F0" id="prB0">02</td>
                      <td align="center" bgcolor="#F0F0F0"><input name="num0" id="fp_inum02" type="text" size="5" alt="_int_"></td>
                    </tr>
                    <TR>
                      <TD align="left" bgcolor="#E3E3E3" id="Date1" >第二行</TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prAp1">10</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num1" id="fp_inum10" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prA1">11</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num1" id="fp_inum11" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prB1">12</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num1" id="fp_inum12" type="text" size="5" alt="_int_"></TD>
                    </TR>
                    <TR>
                      <TD align="left" bgcolor="#F0F0F0" id="Date2" >第三行</TD>
                      <TD align="center" bgcolor="#F0F0F0" id="prAp2">20</TD>
                      <TD align="center" bgcolor="#F0F0F0"><input name="num2" id="fp_inum20" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#F0F0F0" id="prA2">21</TD>
                      <TD align="center" bgcolor="#F0F0F0"><input name="num2" id="fp_inum21" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#F0F0F0" id="prB2">22</TD>
                      <TD align="center" bgcolor="#F0F0F0"><input name="num2" id="fp_inum22" type="text" size="5" alt="_int_"></TD>
                    </TR>
                    <TR>
                      <TD align="left" bgcolor="#E3E3E3" id="Date3" >第四行</TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prAp3">30</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num3" id="fp_inum30" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prA3">31</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num3" id="fp_inum31" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prB3">32</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num3" id="fp_inum32" type="text" size="5" alt="_int_"></TD>
                    </TR>
                    <TR>
                      <TD align="left" bgcolor="#F0F0F0" id="Date4" >第五行</TD>
                      <TD align="center" bgcolor="#F0F0F0" id="prAp4">40</TD>
                      <TD align="center" bgcolor="#F0F0F0"><input name="num4" id="fp_inum40" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#F0F0F0" id="prA4">41</TD>
                      <TD align="center" bgcolor="#F0F0F0"><input name="num4" id="fp_inum41" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#F0F0F0" id="prB4">42</TD>
                      <TD align="center" bgcolor="#F0F0F0"><input name="num4" id="fp_inum42" type="text" size="5" alt="_int_"></TD>
                    </TR>
                    <TR>
                      <TD align="left" bgcolor="#E3E3E3" id="Date5" >第六行</TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prAp5">50</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num5" id="fp_inum50" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prA5">51</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num5" id="fp_inum51" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prB5">52</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num5" id="fp_inum52" type="text" size="5" alt="_int_"></TD>
                    </TR>
                    <TR>
                      <TD align="left" bgcolor="#F0F0F0" id="Date6" >第七行</TD>
                      <TD align="center" bgcolor="#F0F0F0" id="prAp6">60</TD>
                      <TD align="center" bgcolor="#F0F0F0"><input name="num6" id="fp_inum60" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#F0F0F0" id="prA6">61</TD>
                      <TD align="center" bgcolor="#F0F0F0"><input name="num6" id="fp_inum61" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#F0F0F0" id="prB6">62</TD>
                      <TD align="center" bgcolor="#F0F0F0"><input name="num6" id="fp_inum62" type="text" size="5" alt="_int_"></TD>
                    </TR>
                    <TR>
                      <TD align="left" bgcolor="#E3E3E3" id="Date7" >第八行</TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prAp7">70</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num7" id="fp_inum70" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prA7">71</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num7" id="fp_inum71" type="text" size="5" alt="_int_"></TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prB7">72</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num7" id="fp_inum72" type="text" size="5" alt="_int_"></TD>
                    </TR>
                    <TR>
                      <TD align="left" bgcolor="#F0F0F0" id="Date8" >第九行 </TD>
                      <TD align="center" bgcolor="#F0F0F0" id="prAp8">80</TD>
                      <TD align="center" bgcolor="#F0F0F0"><input name="num8" id="fp_inum80" type="text" size="5"  alt="_int_"></TD>
                      <TD align="center" bgcolor="#F0F0F0" id="prA8">81</TD>
                      <TD align="center" bgcolor="#F0F0F0"><input name="num8" id="fp_inum81" type="text" size="5"  alt="_int_"></TD>
                      <TD align="center" bgcolor="#F0F0F0" id="prB8">82</TD>
                      <TD align="center" bgcolor="#F0F0F0"><input name="num8" id="fp_inum82" type="text" size="5"  alt="_int_"></TD>
                    </TR>
                    <TR>
                      <TD align="left" bgcolor="#E3E3E3" id="Date9" >第十行 </TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prAp9">90</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num9" id="fp_inum90" type="text" size="5"  alt="_int_"></TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prA9">91</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num9" id="fp_inum91" type="text" size="5"  alt="_int_"></TD>
                      <TD align="center" bgcolor="#E3E3E3" id="prB9">92</TD>
                      <TD align="center" bgcolor="#E3E3E3"><input name="num9" id="fp_inum92" type="text" size="5"  alt="_int_"></TD>
                    </TR>
          
            </table>
        </form>
            <input type="button" value="test" οnclick="calprice();" >
             
</body>
</html>

最后

以上就是彪壮期待为你收集整理的javascript eval函数的应用,循环合并表格内容的全部内容,希望文章能够帮你解决javascript eval函数的应用,循环合并表格内容所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部