注册 登录
编程论坛 ASP技术论坛

“aspic”老师再请教

zzzhhhyyy 发布于 2009-08-03 20:19, 340 次点击
<html>
<head>


<script language="javascript">
var A =function(ID)
{return document.getElementById(ID);}
get =function(){
   A('A1').value = A('A2').value = A('A3').value = A('A4').value = A('A5').value =A('A_value').value;
}
   
</script>
</head>




<body>
<form>
    <p>●:A<input type="text" id="A_value" style=" height:20; width:20"/>
          B<input type="text" id="B_value" style=" height:20; width:20"/>                              

                                                                   </p>
    <p><input type="BUTTON" value="确定查看" onClick="get()" ></p>
    <p>====================================================</p>
     <form>
        <p>
         ①:A<input type="text" id="A1" style=" height:20; width:20"/>
            B<input type="text" id="B1" style=" height:20; width:20"/></p>
      <p>②:A<input type="text" id="A2" style=" height:20; width:20"/>
            B<input type="text" id="B2" style=" height:20; width:20"/></p>
      <p>③:A<input type="text" id="A3" style=" height:20; width:20"/>
            B<input type="text" id="B3" style=" height:20; width:20"/></p>
      <p>④:A<input type="text" id="A4" style=" height:20; width:20"/>
            B<input type="text" id="B4" style=" height:20; width:20"/></p>
      <p>⑤:A<input type="text" id="A5" style=" height:20; width:20"/>
            B<input type="text" id="B5" style=" height:20; width:20"/></p>
</form>
</body>
</html>
*****************************************************************************
aspic老师:
      感谢你的指导
          在●:A框填入“1”
点击(确定查看)
下面的①A框里就能显示“1”
           ①A框能显示;
        ②③④⑤A框都能显示了。
                          还有个问题
                              在●:B框怎么表达
                                   (我还要做很多个“CDEFG......”)      
                                             (怎样才能类推)
      


谢谢啦!!!
3 回复
#2
aspic2009-08-04 08:39
A('A1').value = A('A2').value = A('A3').value = A('A4').value = A('A5').value =A('A_value').value;
A('B1').value = A('B2').value = A('B3').value = A('B4').value = A('B5').value =A('B_value').value;
全部填上去 如果都是同值的话 只是改变一个名称而已 名称就是为了让它能认出谁是谁

[[it] 本帖最后由 aspic 于 2009-8-4 08:42 编辑 [/it]]
#3
aspic2009-08-04 08:50
程序代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. xmlns="http://www. http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
var $ = function(obj) {return document.getElementById(obj);}
function setValue() {
    var A = $('A').value;
    var B = $('B').value;
    //var C = $('C').value;
    //for循环 依次赋值
    for(var i = 1; i<=5; i++) {
        $('A'+i).value = A;
        $('B'+i).value = B;
        //还有其他CDEFG照样丢下来
        //$('C'+i).value = C;
    }
}
</script>
</head>

<body>
<form id="form">
    <p>A<input type="text" id="A" style=" height:20; width:20"/>B<input type="text" id="B" style="height:20; width:20"/><input type="button" onclick="setValue()" value="点击查看" /></p>
    <p>①:A<input type="text" id="A1" style=" height:20; width:20"/>B<input type="text" id="B1" style=" height:20; width:20"/></p>
    <p>②:A<input type="text" id="A2" style=" height:20; width:20"/>B<input type="text" id="B2" style=" height:20; width:20"/></p>
    <p>③:A<input type="text" id="A3" style=" height:20; width:20"/>B<input type="text" id="B3" style=" height:20; width:20"/></p>
    <p>④:A<input type="text" id="A4" style=" height:20; width:20"/>B<input type="text" id="B4" style=" height:20; width:20"/></p>
    <p>⑤:A<input type="text" id="A5" style=" height:20; width:20"/>B<input type="text" id="B5" style=" height:20; width:20"/></p>
</form>
</body>
</html>
#4
zzzhhhyyy2009-08-04 13:32
aspic老师感谢你的指导!!!
1