How to retrive value of 17 textBox in an array Using javascript

后端 未结 1 751
太阳男子
太阳男子 2021-01-24 03:17

I have Written the code below which is too long. I want some shorter code:

b[0]=parseInt(document.getElementById(\"textbox1\").value);
b[1]=parseInt(document.get         


        
相关标签:
1条回答
  • 2021-01-24 03:31

    Well, as the numbers of the text boxes appear to increase by 3 each time, a simple loop should do it:

    var i;
    for (i = 0; i < 17; ++i) {
       b[i] = parseInt(document.getElementById("textbox" + (i * 3 + 1)).value);
    }
    
    0 讨论(0)
提交回复
热议问题