以下是我的部分代码,下面的其中这部分 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>
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>
解决方案 »
- $("#msg").eq(0)[0] 后面的[0]什么意思
- 我想輸入用戶的ID後 換行自動帶出用戶其他的信息 於是想用onmouseover(),onmouseout() 調用****.do 實現對action類 ****.java 的操作, 查出用戶信息..... 請賜教 先謝謝了 !!!!!!!
- javaScript面向对象中关于对象的事件的问题
- 求正则:将 2007-8-16 格式转换为 07.8.16 格式
- window.parent.do()调用不了iframe父页面的方法,求解
- 急~~如何把我在JAVASCRIPT里定义的一个数组保存到REQUEST中~~
- 不是web页面一加载就先解释JAVASRIPT代码?
- 问题转贴,在线等待,马上给分
- 请问如何用javascript实现延迟功能??
- canvas 拖动矩形边框改变大小
- 关于使用htmlfile对象长连接的问题
- 菜鸟级别的JS问题,大家帮帮我吧!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD><BODY>
<form id="a" name="form1" id="form1">
<input type="text" id="b_1" value=sssss>
</form>
<script>
var i = 1;
var s = "b_"+1 ;
alert(eval("document.form1."+s+".value"));
</script>
</BODY>
</HTML>
这样行啊,你直接加个循环就OK了
<input type="text" name="spbh_2" id="spbh_2">
<script>
var spbh="好心的朋友"
var i =4-3;
var j=i+1;
var sp="spbh_"+j;
document.spkfkForm.elements(sp).value=spbh
</script>
</form>