Results 1 to 5 of 5

Thread: how to use getElementsByName() function in java script?

  1. #1
    Join Date
    Feb 2008
    Posts
    7

    Default how to use getElementsByName() function in java script?

     

    when i am using getElementsByName() in javascript to access a input field in html i am getting error that "object does not support this proparty" how to solve this problem ?
    Powered by Yahoo!

  2. #2

    Default

    What is your code?
    Powered by Yahoo!

  3. #3
    Join Date
    Mar 2008
    Posts
    1

    Default

    The getElementsByName() method returns a collection of objects with the specified NAME.
    example:
    <html>
    <head>
    <script type="text/javascript">
    function getElements()
    {
    var x=document.getElementsByName("myInput");
    alert(x.length);
    }
    </script>
    </head>
    <body><input name="myInput" type="text" size="20" /><br />
    <input name="myInput" type="text" size="20" /><br />
    <input name="myInput" type="text" size="20" /><br />
    <br />
    <input type="button" onclick="getElements()"
    value="How many elements named 'myInput'?" /></body>
    </html>
    Powered by Yahoo!

  4. #4
    Join Date
    Nov 2009
    Posts
    1

    Default I'm not a 100% sure

    I suppose you could try enclosing your inputs in <form> </form>.

  5. #5
    Join Date
    Mar 2010
    Posts
    1

    Default

    raidenn you are right on this

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •