Fix for using EVAL command in JS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Eric
    New Member
    • Jun 2011
    • 2

    Fix for using EVAL command in JS

    I have js that works ok in IE but Firefox returns the error message "Document.f orms is not a function" on ht eline that begins with the "For" operator.

    Ya, I'm a real nube.. is it obvious?

    Code:
    fms='document.forms(tempFormName)'
    for (i=0; i<eval(fms+'.length'); i++)
    Thanks in advance!!
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    that’s correct, there is no forms() method in the document object (that is JScript only). but why should you have more than one form with the same name?

    in standard DOM you access forms by:
    Code:
    // by index number (in document order)
    document.forms[form_number]
    // by known name
    document.form_name
    // by unknown name
    document[form_name]
    Last edited by Dormilich; Jun 10 '11, 05:40 AM.

    Comment

    • Eric
      New Member
      • Jun 2011
      • 2

      #3
      Hi Dormilich,
      Thanks for responding so quickly. I was given a task to take a look at some web pages and I find myself asking the same question you did. "Why". I think I may just pass this project onto someone more experienced.

      Thank you

      Comment

      • macem
        New Member
        • Jun 2011
        • 8

        #4
        Hey, strange example, first rule: eval is evil :).

        Comment

        Working...