item not defined using Mozilla?

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

    #1

    item not defined using Mozilla?

    I have a Javascript that makes a tablerow visible ot invisible, that
    works fine in InternetExplore r, but in Mozilla it's unresponsive and I
    get the following Javascript Console error:
    Error: itemeditrow is not defined
    Source File: editform.php
    Line: 45

    Below is the Javascript, and a section of the HTML for that tablerow.

    I don't get it. It looks defined to me. What am I missing?

    Thanks for any help!
    Liam

    <!-- Begin
    function makeItemEditVis ()
    {
    itemeditrow.sty le.visibility = 'visible';
    itemeditrow2.st yle.visibility = 'visible';
    }
    // End -->

    <tr class="label" id="itemeditrow " style="visibili ty:hidden"><td
    colspan="3" class="labelBlu e" bgcolor=#E6EDF5 >item #:
    etc....
  • Lasse Reichstein Nielsen

    #2
    Re: item not defined using Mozilla?

    deja@celticbear .com (LRW) writes:
    [color=blue]
    > I have a Javascript that makes a tablerow visible ot invisible, that
    > works fine in InternetExplore r, but in Mozilla it's unresponsive and I
    > get the following Javascript Console error:
    > Error: itemeditrow is not defined[/color]
    ....
    [color=blue]
    > itemeditrow.sty le.visibility = 'visible';
    > itemeditrow2.st yle.visibility = 'visible';[/color]
    ....[color=blue]
    > <tr class="label" id="itemeditrow " style="visibili ty:hidden"><td[/color]

    Check <URL:http://jibbering.com/faq/#FAQ4_41>

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Mick White

      #3
      Re: item not defined using Mozilla?

      LRW wrote:[color=blue]
      >
      > Thanks for any help!
      > Liam
      >
      > <!-- Begin
      > function makeItemEditVis ()
      > {
      > itemeditrow.sty le.visibility = 'visible';[/color]

      The reference to itemitrow is wrong. Use the dom heirarchy to reference it.
      Mick[color=blue]
      > itemeditrow2.st yle.visibility = 'visible';
      > }
      > // End -->
      >
      > <tr class="label" id="itemeditrow " style="visibili ty:hidden"><td
      > colspan="3" class="labelBlu e" bgcolor=#E6EDF5 >item #:
      > etc....[/color]

      Comment

      • LRW

        #4
        Re: item not defined using Mozilla?

        Lasse Reichstein Nielsen <lrn@hotpop.com > wrote in message news:<zn3u0zhg. fsf@hotpop.com> ...[color=blue]
        > deja@celticbear .com (LRW) writes:
        >[color=green]
        > > I have a Javascript that makes a tablerow visible ot invisible, that
        > > works fine in InternetExplore r, but in Mozilla it's unresponsive and I
        > > get the following Javascript Console error:
        > > Error: itemeditrow is not defined[/color]
        > ...
        >[color=green]
        > > itemeditrow.sty le.visibility = 'visible';
        > > itemeditrow2.st yle.visibility = 'visible';[/color]
        > ...[color=green]
        > > <tr class="label" id="itemeditrow " style="visibili ty:hidden"><td[/color]
        >
        > Check <URL:http://jibbering.com/faq/#FAQ4_41>
        >[/color]

        Thanks for the reply!
        So, odd. I changed the lines to:
        document.form1. itemeditrow.sty le.visibility = 'visible';
        document.form1. itemeditrow2.st yle.visibility = 'visible';
        And I no longer get the "not defined" error, except, now not only does
        it not work in Mozilla but also stopped working in IE.

        And the form tag has name="form1". Then I added id="form1" but no
        change.

        I have no idea if this is related, but in the Mozilla JavaScript
        Console I'm also getting the error:

        "document.form1 .itemeditrow has no properties"
        It's refering to the line that has:
        document.form1. itemeditrow.sty le.display = 'block';

        Isn't 'block' a property for "display"?

        =P
        Thanks for the help!
        Liam

        Comment

        • Michael Winter

          #5
          Re: item not defined using Mozilla?

          On 14 Sep 2004 08:16:48 -0700, LRW <deja@celticbea r.com> wrote:

          [snip]
          [color=blue]
          > Thanks for the reply!
          > So, odd. I changed the lines to:
          > document.form1. itemeditrow.sty le.visibility = 'visible';
          > document.form1. itemeditrow2.st yle.visibility = 'visible';
          > And I no longer get the "not defined" error, except, now not only does
          > it not work in Mozilla but also stopped working in IE.[/color]

          Can you answer this question: How does placing a table row in a form allow
          you to access that row as if it were a form control?

          Logic alone should tell you that it doesn't. There is no correlation
          between form controls and table components. It appears that you missed the
          point of the link Lasse gave you. You need to access the row using the id,
          but in a cross-browser fashion.

          if(document.get ElementById) {
          var itmRow = document.getEle mentById('iteme ditrow');

          if(itmRow && itmRow.style) {
          itmRow.style.di splay = 'block';
          }
          }

          [snip]
          [color=blue]
          > I have no idea if this is related, but in the Mozilla JavaScript
          > Console I'm also getting the error:
          >
          > "document.form1 .itemeditrow has no properties"
          > It's refering to the line that has:
          > document.form1. itemeditrow.sty le.display = 'block';
          >
          > Isn't 'block' a property for "display"?[/color]

          Yes, it is, but that's not the error. Because the form doesn't contain the
          row, document.form1. itemeditrow evaluates to undefined. Obviously, you
          can't access a property that doesn't exist, and that's why Mozilla says
          that document.form1. itemeditrow has no properties.

          Hope that helps,
          Mike

          --
          Michael Winter
          Replace ".invalid" with ".uk" to reply by e-mail.

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: item not defined using Mozilla?

            LRW wrote:
            [color=blue]
            > Lasse Reichstein Nielsen <lrn@hotpop.com > wrote in message
            > news:<zn3u0zhg. fsf@hotpop.com> ...[/color]

            Please do not write attribution novels.
            [color=blue]
            > [...][/color]

            Please trim your quotes.
            [color=blue]
            > So, odd. I changed the lines to:
            > document.form1. itemeditrow.sty le.visibility = 'visible';
            > document.form1. itemeditrow2.st yle.visibility = 'visible';
            > And I no longer get the "not defined" error, except, now not only does
            > it not work in Mozilla but also stopped working in IE.[/color]

            There is no (form) element with ID "itemeditro w2" in your document.
            [color=blue]
            > And the form tag has name="form1".[/color]

            It is not the "form tag", there is no such thing. You mean the "form"
            element and have the initial value of the "name" attribute of that element
            replaced with the value "form1" by including an attribute-value pair in
            its start tag (<form>).
            [color=blue]
            > Then I added id="form1" but no
            > change.[/color]

            Of course not.
            [color=blue]
            > I have no idea if this is related, but in the Mozilla JavaScript
            > Console I'm also getting the error:
            >
            > "document.form1 .itemeditrow has no properties"[/color]

            It is very much related. This is because null/undefined has no properties.
            [color=blue]
            > It's refering to the line that has:
            > document.form1. itemeditrow.sty le.display = 'block';
            >
            > Isn't 'block' a property for "display"?[/color]

            No, `display' is a (CSS) property and `block' is a possible value for it.

            However, if you refer to the form and then want to refer to an element of
            the form by its ID, you must use the square bracket property accessor and
            the "elements" collection. You should also use the "forms" collection:

            document.forms['form1'].elements['itemeditrow'].style.display = 'block';

            However, you don't want to refer to a form element, i.e. "input" and the
            like, so the target element is _not_ part of the "elements" collection of
            the HTMLFormElement object. The following should work:

            <head>
            <title>...</title>
            ...
            <script type="text/javascript">
            function makeItemEditVis ()
            {
            var t;
            if ((t = typeof document.getEle mentById) == "function"
            || (t == "object" && document.getEle mentById))
            {
            for (var i = arguments.lengt h; i--;)
            {
            var o = document.getEle mentById(argume nts[i]);
            if (o
            && typeof o.style != "undefined"
            && typeof o.style.visibil ity != "undefined" )
            {
            o.style.visibil ity = 'visible';
            }
            }
            }
            }
            </script>

            <style type="text/css">
            .labelBlue {
            background-color:#ccf;
            color:#000;
            }
            </style>
            </head>

            <body>
            <form action="...">
            <table>
            <tr class="label" id="itemeditrow " style="visibili ty:hidden">
            <td colspan="3" class="labelBlu e">item #:</td>
            ...
            </tr>
            ...
            </table>
            ...
            <script type="text/javascript">
            document.write(
            '<input type="button"'
            + ' onclick="makeIt emEditVis(\'ite meditrow\','
            + ' \'itemeditrow2\ ');">');
            </script>
            ...
            </form>

            As you can see, do not mix CSS and formatting attributes, and use
            secure colors only; also remove the SGML Comment Opener and Closer,
            they are obsolete (even though it is described differently in the
            HTML 4.01 Specification).


            HTH

            PointedEars
            --
            Management dictated that no bugs should ever make it to production. We no
            longer put code in production.

            Comment

            • Dr John Stockton

              #7
              Re: item not defined using Mozilla?

              JRS: In article <37783823.DL1ad JeNdq@PointedEa rs.de>, dated Mon, 20 Sep
              2004 19:41:55, seen in news:comp.lang. javascript, Thomas 'PointedEars'
              Lahn <PointedEars@we b.de> posted :[color=blue]
              >LRW wrote:
              >[color=green]
              >> Lasse Reichstein Nielsen <lrn@hotpop.com > wrote in message
              >> news:<zn3u0zhg. fsf@hotpop.com> ...[/color]
              >
              >Please do not write attribution novels.[/color]

              It is permissible for Lahn's home hierarchy, news:de.*, to hold such
              views. But, like the events of 1939-09-01 and 1940-04-09, it is now
              internationally considered to be a Mistake.

              Present Usenet thinking encourages proper attributions; see Usefor work-
              in-progress at
              Read more about the Internet Engineering Task Force (IETF), the premier standards development organization (SDO) for the Internet.

              Read more about the Internet Engineering Task Force (IETF), the premier standards development organization (SDO) for the Internet.



              An informative attribution would have made it clear that the idiot
              savant child Lahn is, once more, contributing to an ancient thread.


              <FAQENTRY>
              The FAQ should cite the above, or successor, documents; and perhaps also
              that in sig line 2, which is so widely useful.

              --
              © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME ©
              Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
              Web <URL:http://www.merlyn.demo n.co.uk/news-use.htm> : about usage of News.
              No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.

              Comment

              Working...