<p>I'm writing a HTML form that's divided in fieldsets, and I need to get the form fields from a specific fiedset in a function.<br>
Currently it's like this:  </p>

<pre><code>function conta(Fieldset){  
    var Inputs = Fieldset.getElementsByTagName("input");  
    var Selects = Fieldset.getElementsByTagName("select");  
    /* Doing the stuff I need to do in two iterations, one for each field type */  
}
</code></pre>

<p>But who knows what the future may hold, and if the form gets some new field types (radios, checkboxes) this could become awful to mantain.<br>
I know that <code>form</code> elements have the  <code>elements</code> attribute that returns all the form fields and I was hoping I could use something like that.<br>
(I know I still gotta discriminate the field type in a bunch of conditionals inside the iteration, but I think it would be faster and easier to keep. Unless it isn't and I should not be doing it)</p>

Haven't tested this and don't know how it would work, but you could use JQuery here to select all the elements into a JQuery object
```
```
//$("input select textarea").each(function() {
$(":input").each(function() { //even better
    // do stuff here
});
```
```
this would at least cleanup the code, although you would still have to add conditional statements based on field type like you mentioned.