Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: walking the dom

  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    190
    Thanks
    1
    Thanked 2 Times in 2 Posts

    walking the dom

    i have a div that has a table with form fields in it. i want to single out those fields and loop through them and validate their values. how would i do that?

    document.getElementsByTagName would work, its just that it would pull every element with that tagname, i just want the ones in that div, and im only checking to see if they're blank.

    thanks

    example:
    <div id="container">
    <form>
    <input id="nameField">
    <input id="siteField">

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    190
    Thanks
    1
    Thanked 2 Times in 2 Posts
    got it

    Code:
    function validatex(){
    	var dom = document.getElementById('shout_form');
    	var dom2 = dom.getElementsByTagName('input');
    	for(var i = 0; i < dom2.length; i++){
    		alert(dom2[i].id);
    	}
    }


  •  

    Posting Permissions

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