Question: I'm looking for either a best practise or library for processing string into an object tree..

here is the example:

"[age] = '37' And [gender] Is Not Null And [optindate] > '2003/01/01' And [idnumber] Is Null And ([saresident] = '52' Or [citizenship] Like 'abc%')"

I should be able to objectize this into a tree something like this:

```
{attribute='age', operator='=', value='37', opperand='And'}
{attribute='gender', operator='Is Not Null', value='', opperand='And'}
{attribute='optindate', operator='>', value='2003/01/01', opperand='And'}

```

etc....

any suggestions would be great!

Answer: 
We have no way of knowing how type should be treated - you haven't show us how the function is being called (in particular, we don't know what you are passing as its argument).

If it *is* a string (matching the id of an element), than `document.getElementById(type).checked` should work (although `== true` is redundant).

`document.nav.type.checked` should not work, because dot-notation property names are not interpolated. You have to use [square bracket notation](http://www.dev-archive.net/articles/js-dot-notation/) for that: `document.forms.nav.elements[type].checked`. This will match on name or id - if you have multiple elements with the same name, then `document.forms.nav.elements[type]` will be an object you can treat as an array (and won't have a checked property).
you can as well compare with "true"