以下是我的部分代码,下面的其中这部分 var i =testTbl.rows.length-3;
   var j=i+1;
构造document.spkfkForm.spbh_j.value=spbh;
这个spbh_j我要取上面定义好的值,不晓得怎么取不到?
构造一个JavaScript动态变量!该怎么构造。 我用了document.spkfkForm.spbh_'+j+'.value=spbh;也不行 ,document.spkfkForm.“spbh_”+j.value=spbh;也不行 
eval("document.spkfkForm.spbh_"+j+".value=spbh");
都不行,请问那位好心的朋友帮我解决这个问题呀,急着赶项目!怎么样来构造一个变量让他自动能调用到变量,当执行第一次的时候为spbh_1,第二次spbh_2,一直循环!<script type="text/javascript">
function display(){
   var i =testTbl.rows.length-3;
   var j=i+1;
   var sp="spbh_"+j;
   alert(sp);
    var ser = window.showModalDialog("/sksoft/admin/window/displayspkfk.action","","dialogHeight:400px;dialogWidth:720px;center:yes;help:no;resizable:no;status:no;");
    if (ser) {
     var spkfkLen=ser.length;
     var firstLen=ser.indexOf(",",0);
     var secondLen=ser.indexOf(",",firstLen+1);
     var threeLen=ser.indexOf(",",secondLen+1);
     var fourLen=ser.indexOf(",",threeLen+1);
     var fiveLen=ser.indexOf(",",fourLen+1);
     var sixLen=ser.indexOf(",",fiveLen+1)
     var sevenLen=ser.indexOf(",",sixLen+1);
     var eightLen=ser.indexOf(",",sevenLen+1);
     var spbh;
     var spmch;
     var shpgg;
     var dw;
     var pizhwh;
     var chbdj;
     var shpchd;
     var jlgg;
     if (firstLen != -1) {
     spbh=ser.substring(0,firstLen);
     document.spkfkForm.spbh_j.value=spbh;
     if (secondLen != -1) {
     spmch=ser.substring(firstLen+1,secondLen);
     document.spkfkForm.spmch_j.value=spmch;
     if (threeLen !=-1) {
     shpgg=ser.substring(secondLen+1,threeLen);
     document.spkfkForm.shpgg_j.value=shpgg;
     if (fourLen !=-1) {
     dw=ser.substring(threeLen+1,fourLen);
     document.spkfkForm.dw_j.value=dw;
     if (fiveLen !=-1) {
     pizhwh=ser.substring(fourLen+1,fiveLen);
     document.spkfkForm.pizhwh_j.value=pizhwh;
     if (sixLen != -1) {
     chbdj=ser.substring(fiveLen+1,sixLen);
     document.spkfkForm.chbdj_j.value=chbdj;
     if (sevenLen != -1) {
     shpchd=ser.substring(sixLen+1,sevenLen)
    
    
    
    
     ;
     document.spkfkForm.shpchd_j.value=shpchd;
     if (eightLen != -1) {
     jlgg=ser.substring(sevenLen+1,eightLen);
     document.spkfkForm.jlgg_j.value=jlgg;
     }else if (eightLen == -1) {
     jlgg=ser.substring(sevenLen+1,spkfkLen);
     document.spkfkForm.jlgg_j.value=jlgg;
     }
     }else if (sevenLen == -1) {
     shpchd=ser.substring(sixLen+1,spkfkLen);
     document.spkfkForm.shpchd_j.value=shpchd;
     }
     }else if (sixLen == -1) {
     chbdj=ser.substring(fiveLen+1,spkfkLen);
     document.spkfkForm.chbdj_j.value=chbdj;
     }
     }else if(fiveLen == -1) {
     pizhwh=ser.substring(fourLen+1,spkfkLen);
     document.spkfkForm.pizhwh_j.value=pizhwh;
     } 
     }else if (fourLen == -1) {
     dw=ser.substring(threeLen+1,spkfkLen);
     document.spkfkForm.dw_j.value=dw;
     }
     }else if (threeLen == -1) {
     shpgg=ser.substring(secondLen+1,spkfkLen);
     document.spkfkForm.shpgg_j.value=shpgg;
     }
     }else if (secondLen == -1) {
     spmch=ser.substring(firstLen+1,spkfkLen);
     document.spkfkForm.spmch_j.value=spmch;
     }
     }else if (firstLen == -1){
     spbh=ser.substring(0,spkfkLen);
     document.spkfkForm.spbh_j.value=spbh;
     }
    } 
  
  }
  
  function addRows()
  {
   var i =testTbl.rows.length-2;
   var j=i+1;
   alert(j);
   var newTr = testTbl.insertRow();
   var newTd=newTr.insertCell();
   var newTd0 = newTr.insertCell();
   var newTd1 = newTr.insertCell();
   var newTd2 = newTr.insertCell();
   var newTd3 = newTr.insertCell();
   var newTd4 = newTr.insertCell();
   var newTd5 = newTr.insertCell();
   var newTd6 = newTr.insertCell();
   var newTd7 = newTr.insertCell();
   var newTd8 = newTr.insertCell();
   var newTd9 = newTr.insertCell();
   var newTd10 = newTr.insertCell();
   var newTd11 = newTr.insertCell();
   var newTd12 = newTr.insertCell();
     newTd.innerHTML = '<input name="xuhao_'+j+'" type="text" class="input" style="width: 1pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';
    newTd.innerText= j;
    newTd0.innerHTML = '<input name="spbh_'+j+'" type="text" class="input" style="width: 80pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';
    newTd1.innerHTML = '<input name="shpgg_'+j+'" type="text" class="input" style="width: 80pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';
    newTd2.innerHTML = '<input name="dw_'+j+'" type="text" class="input" style="width: 80pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';
    newTd3.innerHTML = '<input name="pizhwh_'+j+'" type="text" class="input" style="width: 80pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';
    newTd4.innerHTML = '<input name="shl_'+j+'" type="text" class="input" style="width: 80pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';
    newTd5.innerHTML = '<input name="chbdj_'+j+'" type="text" class="input" style="width: 80pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';
    newTd6.innerHTML = '<input name="bm_'+j+'" type="text" class="input" style="width: 80pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';
    newTd7.innerHTML = '<input name="spbh_'+j+'" type="text" class="input" style="width: 80pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';
    newTd8.innerHTML = '<input name="spbh_'+j+'" type="text" class="input" style="width: 80pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';
    newTd9.innerHTML = '<input name="spbh_'+j+'" type="text" class="input" style="width: 80pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';
    newTd10.innerHTML = '<input name="shpchd_'+j+'" type="text" class="input" style="width: 80pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';
    newTd11.innerHTML = '<input name="jlgg_'+j+'" type="text" class="input" style="width: 80pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';
    newTd12.innerHTML = '<input name="bz_'+j+'" type="text" class="input" style="width: 80pt; border: 0; border-bottom: 0 solid #307ab7; background: ;">';    newTd12.onclick = addRows;    newTr.ondblclick = display;
   
   
  }
</script>