issues with form elements

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • john

    #1

    issues with form elements

    if I have
    if (document.form[0].element[0].type == "select")
    and I have a form with at liest 1 element on the page this should work
    right?

    I keep getting a "document.form. 0 is null or not an object" message any
    idea why?

    john
  • Evertjan.

    #2
    Re: issues with form elements

    john <wenjoh26@emNOS PAMail@pct.edu> wrote in
    news:Xns9409AE6 345D4wenjoh26em NOSPAMailp@216. 65.98.9:
    [color=blue]
    > if I have
    > if (document.form[0].element[0].type == "select")
    > and I have a form with at liest 1 element on the page this should work
    > right?
    >
    > I keep getting a "document.form. 0 is null or not an object" message any
    > idea why?[/color]

    document.forms[0].elements[0].

    ??

    Comment

    • Richard Cornford

      #3
      Re: issues with form elements

      "Evertjan." <none@none.nl > wrote in message
      news:Xns9409503 86CF80eejj99@19 4.109.133.29...[color=blue]
      >john <wenjoh26@emNOS PAMail@pct.edu> wrote in
      >news:Xns9409AE 6345D4wenjoh26e mNOSPAMailp@216 .65.98.9:[color=green]
      >>if I have
      >>if (document.form[0].element[0].type == "select")
      >>and I have a form with at liest 1 element on the page
      >>this should work right?
      >>
      >> I keep getting a "document.form. 0 is null or not an object"
      >>message any idea why?[/color]
      >
      >document.for ms[0].elements[0].[/color]

      However, from the W3C HTML DOM specs:-

      Interface HTMLSelectEleme nt
      type of type DOMString, readonly.
      The type of this form control. This is the string
      "select-multiple" when the multiple attribute is true
      and the string "select-one" when false.

      -so comparison with the string "select" should not be expected to work.
      But, IceBrowser 5 is an example of at least one browser that erroneously
      assigns the string "select" to the - type - property of a SELECT element
      so it might be best to check to see if the - type - property contains
      the substring "select" (and then maybe the - multiple - property if that
      is important).

      Richard.


      Comment

      Working...