×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

see inline

actually i can't understand the reason u need it as the array...
for syntax, chk: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/getelementsbytagname.asp

maybe i misunderstood the question. what i want to say is, you can use obj1.getElementByTagName to get the object collection under obj1 then you can iterate that collection, right?
you can 'group' your INPUT controls set by any object, for example,
<span id="row1">
<input id="cell1">
<input id="cell2">
<input id="cell3">
</span>
<span id="row2">
<input id="cell1">
<input id="cell2">
<input id="cell3">
</span>
therefore, you can use
var arrINPUTRow1 = document.getElementById("row1").getElementsByTagName("INPUT");

again, maybe i just misunderstood your requirements...
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / Hi, friends, Happy long weekwend.Here i have some problems with javascript.
    本文发表在 rolia.net 枫下论坛Hi, friends, Happy long weekwend.Here i have some problems with javascript.
    Could you guys give me some solutions? Thank you in advance.
    1.how to plus mathematically?
    What I get is 2+3=23.Give me an example please.
    2.in terms of form, the name of the input can't be array? but I really want it.
    In the following code, I want:
    1.get the result of n1+n2+n3
    2, the name of input use array.
    But I can't, Could you guys show me a solution.
    Thanks a lot.
    ------------------------------------

    <html>
    <head>
    <title>try</title>
    <script language="Javascript">
    var row1()=new Array();
    var row2()=new Array();
    var row3()=new Array();

    function plus()
    {
    var r1=document.theform.row1(1).value;
    var r2=document.theform.row2(1).value;
    var r3=document.theform.row3(1).value;
    var result=r1+r2+r3
    alert (r1+"pluses"+r2+"plues"+r3+"is"+result)
    }

    </script>
    </head>
    <body>
    <form name="theform" >
    n1<input type="text" name="row1(1)"><br>
    n2<input type="text" name="row2(1)"><br>
    n3<input type="text" name="row3(1)"><br>
    <a href="#" onClick="plus();return false">plus</a>
    </form>
    </body>
    </html>更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • 1,你需要先转换一下数据类型。2,没这种用法,死心了吧
      • what's the syntax for converting data type? Thanks.
    • 1. parseInt(n, 10) 2. var arrINPUT = document.getElementsByTagName("INPUT")
      • How to use the second syntax in my sample code?Could you please show me? I am just a begainer. Thanks a lot.
        • see inline
          actually i can't understand the reason u need it as the array...
          for syntax, chk: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/getelementsbytagname.asp

          maybe i misunderstood the question. what i want to say is, you can use obj1.getElementByTagName to get the object collection under obj1 then you can iterate that collection, right?
          you can 'group' your INPUT controls set by any object, for example,
          <span id="row1">
          <input id="cell1">
          <input id="cell2">
          <input id="cell3">
          </span>
          <span id="row2">
          <input id="cell1">
          <input id="cell2">
          <input id="cell3">
          </span>
          therefore, you can use
          var arrINPUTRow1 = document.getElementById("row1").getElementsByTagName("INPUT");

          again, maybe i just misunderstood your requirements...
          • Thank you, I''ll check out how it works.
      • 第一个问题不用这么麻烦
        result=val1*1+val2*1+val3*1;

        没有试过。从经验来讲可行。