getElementsByName() properties not working inside loop !!

Discussion in 'JavaScript' started by ximpda, Feb 27, 2008.

  1. #1
       var textboxes = document.getElementsByName("textbx");
            var i=0;
            
            for (i=0;i<=textboxes.length;i++)
            {
                document.write ("Looping " + i + " time");
    
                 document.write(textboxes[i].value);
                
            }
    HTML:


    Would any one please explain why this part of code isnt working ??

    if i put the chkboxes.length outside the loop, then it prints out the values properly. But inside the loop it doesnt work at all!

    Please help !!
     
    ximpda, Feb 27, 2008 IP
  2. blacknet

    blacknet Active Member

    Messages:
    709
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    70
    #2
    try:
    textboxes.item(i).value

    ps: hope you have inputs with a name of "textbx"
    + where does chkboxes.length come in to it?
     
    blacknet, Feb 27, 2008 IP