title: JavaScript for loop to set attribute
body: <ol>
  <li><p>I have several <code>&lt;input&gt;</code> tags. I want to change the type to number if it is <code>type="text"</code>,so I make a loop function but that doesn't work and no error appears.</p>
  
  <p>(I don't know how to make it change from <code>&lt;input type="text"&gt;</code> to <code>&lt;input type="number"&gt;</code> when I load this page because there are many tags so I think it's fast to use <code>for</code> loop )</p>
  
  <pre><code>var a=document.getElementsByTagName("input")[i].getAttribute("type");
  function setvalue(){
      for(i=0;i&lt;a.length;i++){
          var b=document.getElementsByTagName("input")[i]
          if (a="text"){
              b.setAttribute("text","number");
          }
      }
  }
  </code></pre></li>
  <li><p>I have several <code>&lt;select&gt;</code> tags in other page, which looks like <code>&lt;select id="inp_015"&gt; &lt;select id="inp_025"&gt;... &lt;select id="inp_105"&gt;..&lt;select id="inp_205"&gt;</code> the last number is 5 and the front is from 01 to 20)
  I want to change its width. I made some code below but also don't work.</p>
  
  <pre><code>for(i=0;i&lt;3;i++){
      for(i=1;y&lt;10;i++){
          document.getElementById("inp_"+"i"+"y"+"5").style.width="125px";
      }
  }
  </code></pre></li>
  </ol>
  
  <hr>
  
  <p>editted</p>
  
  <pre><code>function setwidth(){
      for(i=0;i&lt;3;i++){
      for(y=1;y&lt;10;i++){
      document.getElementById("inp_"+i+y+"5").style.width="125px";
  }}}
  </code></pre>
  
  <p>(My script was put at the bottom of the body tag)
  I hope I can get to know which part went wrong.</p>