[thelist] Form sniffing within tables nested within divs

Chris Marsh chris at webbtech.co.uk
Wed Nov 6 13:15:11 CST 2002


> > Hopefully this would give me a set of name/key pairs of all
> the forms
> > on the page. In fact this is *exactly* what I want to do,
> but limit it
> > to any forms nested within a certain div, the id for which
> is set in
> > tablets of stone.
>
> How will you know which div you are trying to work with?

Because I know what the id of the div is. Thus, in pseudocode:

function GetForms() {
  var o = new Object;
  var fo = document.forms;
  var fl = of.length;
  var d = document.getElementById("IKnowWhatThisDivIsCalled");
  for(i=0;i<fl;i++) {
    if(form is a child, grandchild etc. of d ) {
      var eo = fo[i].elements;
      var el = eo.length;
      for(j=0;j<el;j++) {
        if(eo[j].type.indexOf("submit") > -1) {
          o.eo[j].value] = i;
        }
      }
    }
  }
  return o;
}

What I don't know how to do is to use the DOM (or any other means) of
identifying if a form is lower in the DOM and included in the nesting of
a given element.

Regards

Chris Marsh





More information about the thelist mailing list