Netscape 7.1 getElementById Error

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

    Netscape 7.1 getElementById Error

    Hi,

    I have a javascript function which uses the method
    document.getEle mentById.

    I'm using it to decide whether a checkbox has been ticked or not. This
    decision is encoded in an if statement with the condtion being
    if (document.getEl ementById(check boxtoupdate).va lue ==1)


    /* The Code */

    function set(object)
    {
    var checkboxtoupdat e = object.value;

    if (document.getEl ementById(check boxtoupdate).va lue ==1)
    document.getEle mentById(checkb oxtoupdate).val ue = 0;
    else
    document.getEle mentById(checkb oxtoupdate).val ue = 1;
    }



    The "object" accesses a html tag which has an value attribute e.g
    value="7400"

    However Netscape Navigator 7.1 does not seem to recognise
    "document.getEl ementById(check boxtoupdate).va lue"
    and reports an error that
    document.getEle mentById(checkb oxtoupdate).val ue has no properties.

    But Internet Explorer has no problem with this at all.

    Is there another way to do this so as to be recognised by Netscape
    7.1?
  • ZER0

    #2
    Re: Netscape 7.1 getElementById Error

    On 7 Apr 2004 02:30:10 -0700, Gerry wrote:

    [cut][color=blue]
    > function set(object)
    > {
    > var checkboxtoupdat e = object.value;
    >
    > if (document.getEl ementById(check boxtoupdate).va lue ==1)[/color]
    [cut][color=blue]
    > The "object" accesses a html tag which has an value attribute e.g
    > value="7400"
    >
    > However Netscape Navigator 7.1 does not seem to recognise
    > "document.getEl ementById(check boxtoupdate).va lue"
    > and reports an error that
    > document.getEle mentById(checkb oxtoupdate).val ue has no properties.[/color]

    It's right.
    [color=blue]
    > But Internet Explorer has no problem with this at all.[/color]

    The behavior of IE is wrong. Or better, it doesn't fit standards.

    From W3C:

    ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed
    by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
    colons (":"), and periods (".").

    --
    C'ya,
    ZER0 :: coder.gfxer.web Designer();

    Deformazione professionale รจ:
    Quando in ascensore senti la ragazza accanto che tira fuori il cellulare,
    e ti volti per capire se e' un modello sul quale puoi sviluppare in J2ME.

    Comment

    • Martin Honnen

      #3
      Re: Netscape 7.1 getElementById Error



      Gerry wrote:

      [color=blue]
      > I have a javascript function which uses the method
      > document.getEle mentById.
      >
      > I'm using it to decide whether a checkbox has been ticked or not. This
      > decision is encoded in an if statement with the condtion being
      > if (document.getEl ementById(check boxtoupdate).va lue ==1)
      >
      >
      > /* The Code */
      >
      > function set(object)
      > {
      > var checkboxtoupdat e = object.value;
      >
      > if (document.getEl ementById(check boxtoupdate).va lue ==1)
      > document.getEle mentById(checkb oxtoupdate).val ue = 0;
      > else
      > document.getEle mentById(checkb oxtoupdate).val ue = 1;
      > }
      >
      >
      >
      > The "object" accesses a html tag which has an value attribute e.g
      > value="7400"[/color]

      Is there any element in the page that has
      <tagname id="7400">
      ?? I guess you don't have one but only
      <tagname name="7400">
      --

      Martin Honnen


      Comment

      • Ivo

        #4
        Re: Netscape 7.1 getElementById Error

        "Gerry" wrote[color=blue]
        > I'm using it to decide whether a checkbox has been ticked or not.[/color]

        There is a word for that in javascript: checked. It is an ordinary
        read/write property of any element that can be ticked and unticked. For
        example this line
        if(obj.checked= =true) obj.checked= false
        would see whether the object "obj" is currently ticked, and if so, untick
        it.
        [color=blue]
        > function set(object)
        > {
        > var checkboxtoupdat e = object.value;[/color]

        So checkboxtoupdat e is a value. Fine.
        [color=blue]
        > if (document.getEl ementById(check boxtoupdate).va lue ==1)[/color]

        So checkboxtoupdat e not only *is* but also *has* a value of its own. Eh? Did
        you not mean:
        if (document.getEl ementById(objec t).value ==1)
        [color=blue]
        > document.getEle mentById(checkb oxtoupdate).val ue = 0;
        > else
        > document.getEle mentById(checkb oxtoupdate).val ue = 1;
        > }
        >
        > The "object" accesses a html tag which has an value attribute e.g
        > value="7400"[/color]

        That would be the checkboxtoupdat e variable then.
        [color=blue]
        > However Netscape Navigator 7.1 does not seem to recognise
        > "document.getEl ementById(check boxtoupdate).va lue"
        > and reports an error that
        > document.getEle mentById(checkb oxtoupdate).val ue has no properties.
        >
        > But Internet Explorer has no problem with this at all. Is there another
        > way to do this so as to be recognised by Netscape 7.1?[/color]

        No idea why this works in IE.
        Ivo


        Comment

        • Andy

          #5
          Re: Netscape 7.1 getElementById Error


          I beleive your code should be

          function set(object)
          {
          var checkboxtoupdat e = object.value;

          if (document.getEl ementById(check boxtoupdate).ch ecked ==true)
          document.getEle mentById(checkb oxtoupdate).che cked = false;
          else
          document.getEle mentById(checkb oxtoupdate).che cked = true;
          }
          --
          Andy

          "Gerry" <gerard.morley2 @mail.dcu.ie> wrote in message
          news:10aeb23e.0 404070130.234ec d3@posting.goog le.com...
          Hi,

          I have a javascript function which uses the method
          document.getEle mentById.

          I'm using it to decide whether a checkbox has been ticked or not. This
          decision is encoded in an if statement with the condtion being
          if (document.getEl ementById(check boxtoupdate).va lue ==1)


          /* The Code */

          function set(object)
          {
          var checkboxtoupdat e = object.value;

          if (document.getEl ementById(check boxtoupdate).va lue ==1)
          document.getEle mentById(checkb oxtoupdate).val ue = 0;
          else
          document.getEle mentById(checkb oxtoupdate).val ue = 1;
          }



          The "object" accesses a html tag which has an value attribute e.g
          value="7400"

          However Netscape Navigator 7.1 does not seem to recognise
          "document.getEl ementById(check boxtoupdate).va lue"
          and reports an error that
          document.getEle mentById(checkb oxtoupdate).val ue has no properties.

          But Internet Explorer has no problem with this at all.

          Is there another way to do this so as to be recognised by Netscape
          7.1?


          Comment

          • Randy Webb

            #6
            Re: Netscape 7.1 getElementById Error

            Andy wrote:
            [color=blue]
            > I beleive your code should be[/color]

            You would believe wrong.
            [color=blue]
            > function set(object)
            > {
            > var checkboxtoupdat e = object.value;
            >
            > if (document.getEl ementById(check boxtoupdate).ch ecked ==true)
            > document.getEle mentById(checkb oxtoupdate).che cked = false;
            > else
            > document.getEle mentById(checkb oxtoupdate).che cked = true;
            > }[/color]

            checkboxtoupdat e is a value of an element, as such, it has no "checked"
            property.

            And all of it is totally dependent on how object gets passed.

            set(this.value) ;
            set(this);
            set('objectName );

            And without knowing how set is called, and how object is passed, its
            anybody's guess as to the problem.

            --
            Randy
            Chance Favors The Prepared Mind
            comp.lang.javas cript FAQ - http://jibbering.com/faq/

            Comment

            • Gerry

              #7
              Re: Netscape 7.1 getElementById Error

              Hi again,

              Thanks for your replys,
              [color=blue]
              > checkboxtoupdat e is a value of an element, as such, it has no "checked"
              > property.
              >
              > And all of it is totally dependent on how object gets passed.
              >
              > set(this.value) ;
              > set(this);
              > set('objectName );
              >[/color]

              The object gets passed like this (in the webpage that is)
              OnClick="parent .videoDetailSub mit.set(this)"

              The full tag is as below.

              The id is a different number for each checkbox.

              <input type="checkbox" name="tom" id="{keyFrame/frame}"
              value="{startTi me}" OnClick="parent .videoDetailSub mit.set(this)"[color=blue]
              ></input>[/color]

              a real example of the values for this:
              <input OnClick="parent .videoDetailSub mit.set(this)" value="7400"
              id="366" name="tom" type="checkbox" >

              In my code though i'm using the value attribute ,which 99.9% of the
              time is unique but,in theory, it could be the same value for both
              checkboxes, but when I try and use the unique "id" value , neither IE
              or Netscape can seem to pick up on this with getElementById( object.id)
              Why ever this happens I dont know.


              Gerry.

              Randy Webb <hikksnotathome @aol.com> wrote in message news:<da-dnS5_pfaVsundRV n-jg@comcast.com> ...[color=blue]
              > Andy wrote:
              >[color=green]
              > > I beleive your code should be[/color]
              >
              > You would believe wrong.
              >[color=green]
              > > function set(object)
              > > {
              > > var checkboxtoupdat e = object.value;
              > >
              > > if (document.getEl ementById(check boxtoupdate).ch ecked ==true)
              > > document.getEle mentById(checkb oxtoupdate).che cked = false;
              > > else
              > > document.getEle mentById(checkb oxtoupdate).che cked = true;
              > > }[/color]
              >
              > checkboxtoupdat e is a value of an element, as such, it has no "checked"
              > property.
              >
              > And all of it is totally dependent on how object gets passed.
              >
              > set(this.value) ;
              > set(this);
              > set('objectName );
              >
              > And without knowing how set is called, and how object is passed, its
              > anybody's guess as to the problem.[/color]

              Comment

              • Michael Winter

                #8
                Re: Netscape 7.1 getElementById Error

                On 8 Apr 2004 01:43:39 -0700, Gerry <gerard.morley2 @mail.dcu.ie> wrote:
                [color=blue]
                > The object gets passed like this (in the webpage that is)
                > OnClick="parent .videoDetailSub mit.set(this)"
                >
                > The full tag is as below.
                >
                > The id is a different number for each checkbox.
                >
                > <input type="checkbox" name="tom" id="{keyFrame/frame}"
                > value="{startTi me}" OnClick="parent .videoDetailSub mit.set(this)">
                > </input>[/color]

                INPUT elements do not, and cannot, have closing tags.

                HTML: <input ...>
                XHTML: <input ... />
                [color=blue]
                > a real example of the values for this:
                > <input OnClick="parent .videoDetailSub mit.set(this)" value="7400"
                > id="366" name="tom" type="checkbox" >
                >
                > In my code though i'm using the value attribute ,which 99.9% of the
                > time is unique but,in theory, it could be the same value for both
                > checkboxes, but when I try and use the unique "id" value , neither IE
                > or Netscape can seem to pick up on this with getElementById( object.id)
                > Why ever this happens I dont know.[/color]

                First, read ZER0's post; id values are illegal.

                Second, why would you want to perform

                document.getEle mentById( object.id );

                where object is an element reference? It will simply return object, and so
                the call will just be an expensive waste of time.

                You've now managed to confuse the issue in my mind. First, it appeared
                that the value of a control represented the id of another, and you wanted
                to get a reference to that control through:

                document.getEle mentById( object.value );

                Now it appears that you want a reference to element passed, which you
                already have in "object".

                Mike


                Please, don't top-post.

                --
                Michael Winter
                M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

                Comment

                Working...