Javascript errors in Mozila

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

    Javascript errors in Mozila

    I have a form that I am validating. The script works fine in IE, but
    Mozilla is a defferent story.

    Here is the section that is giving me problems.

    // Preferred contact method
    if ((document.cont act_form["contact_prefer "][0].checked == false)
    && (document.conta ct_form["contact_prefer "][1].checked == false)) {
    field_errors = field_errors+"P referred contact method -
    Please tells us how you would prefer to be contacted \n";
    errors++;

    The Mozilla error reads:
    document.contac t_form["contact_prefer "][0] has no properties.

    Anyone know the answer to this one?

    Thanks
  • cwj

    #2
    Re: Javascript errors in Mozila

    Thanks for your help gang.

    Ended up I didn't need to validate those radio buttons after all, but
    you gave me lots to go on for the next time around.

    Thanks for all the quick responses. Hope I can be as helpful one day.

    CWJ


    On Fri, 09 Jan 2004 06:18:05 GMT, cwj <cwj@nc.rr.co m> wrote:
    [color=blue]
    >I have a form that I am validating. The script works fine in IE, but
    >Mozilla is a defferent story.
    >
    >Here is the section that is giving me problems.
    >
    >// Preferred contact method
    > if ((document.cont act_form["contact_prefer "][0].checked == false)
    >&& (document.conta ct_form["contact_prefer "][1].checked == false)) {
    > field_errors = field_errors+"P referred contact method -
    >Please tells us how you would prefer to be contacted \n";
    > errors++;
    >
    >The Mozilla error reads:
    >document.conta ct_form["contact_prefer "][0] has no properties.
    >
    >Anyone know the answer to this one?
    >
    >Thanks[/color]

    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: Javascript errors in Mozila

      cwj wrote:
      [color=blue]
      > The Mozilla error reads:
      > document.contac t_form["contact_prefer "][0] has no properties.
      >
      > Anyone know the answer to this one?[/color]

      You have not shown the required snippets of the underlying markup, so
      guessing is all what is possible. Let us assume that "contact_fo rm"
      is the name (i.e. the value of the "name" attribute) of a "form" element
      and you try to access the first form control named "contact_prefer ".
      The proper, because standardized, way to access that control is

      document.forms["contact_fo rm"].elements["contact_prefer "][0]

      This works, of course, only if there is more than one control of that
      name, otherwise there is no HTMLCollection object from which to retrieve
      the first item.


      HTH

      PointedEars

      Comment

      Working...