Is Null or Not an OBJECT

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

    Is Null or Not an OBJECT

    I created this select dynamically in a page like:

    var j=4;
    mySELECT = document.create Element("SELECT ");
    mySELECT.name = "MEMBER" + j;
    mySELECT.onclic k = function (evt) { alert(this.name ); }
    myOPTION = document.create Element("OPTION ");
    myOPTION.value= "1";
    myTEXT=document .createTextNode ("first");
    myOPTION.append Child(myTEXT);
    mySELECT.append Child(myOPTION) ;
    myOPTION = document.create Element("OPTION ");
    myOPTION.value= "2";
    myOPTION.select ed="true";
    myTEXT=document .createTextNode ("second");
    myOPTION.append Child(myTEXT);
    mySELECT.append Child(myOPTION) ;
    myTD.appendChil d(mySELECT);

    But then when I try to access it with either:

    document.update .elements['MEMBER4'].value

    or

    document.update .MEMBER4.value

    or

    document.update .elements['MEMBER4'].options[document.update .elements['MEMBER4'].selectedIndex].text;

    I get blah, blah ... 'is null or not an object'.

    I can see the object on the page and when I click on it I get the alert
    message showing the name is "MEMBER4".

    I am stumped why I am getting this message. Something must not be right.
    Could it be that it is not getting created in the form "update"? I need
    to have it created there.

    Any help is appreciated.

    Mike
  • Michael Hill

    #2
    Re: Is Null or Not an OBJECT

    > Could it be that it is not getting created in the form "update"? I need[color=blue]
    > to have it created there.
    >[/color]

    Naw, it is being created in the <form> heirarchy.....

    Comment

    • Dominique

      #3
      Re: Is Null or Not an OBJECT

      try document.all.it em("MEMBER4").v alue

      if this works, then it obviously isn't being created inside the form
      "update"
      :o)

      "Michael Hill" <hillmw@ram.lmt as.lmco.com> wrote in message
      news:409A68E6.2 808E149@ram.lmt as.lmco.com...[color=blue]
      > I created this select dynamically in a page like:
      >
      > var j=4;
      > mySELECT = document.create Element("SELECT ");
      > mySELECT.name = "MEMBER" + j;
      > mySELECT.onclic k = function (evt) { alert(this.name ); }
      > myOPTION = document.create Element("OPTION ");
      > myOPTION.value= "1";
      > myTEXT=document .createTextNode ("first");
      > myOPTION.append Child(myTEXT);
      > mySELECT.append Child(myOPTION) ;
      > myOPTION = document.create Element("OPTION ");
      > myOPTION.value= "2";
      > myOPTION.select ed="true";
      > myTEXT=document .createTextNode ("second");
      > myOPTION.append Child(myTEXT);
      > mySELECT.append Child(myOPTION) ;
      > myTD.appendChil d(mySELECT);
      >
      > But then when I try to access it with either:
      >
      > document.update .elements['MEMBER4'].value
      >
      > or
      >
      > document.update .MEMBER4.value
      >
      > or
      >
      >[/color]
      document.update .elements['MEMBER4'].options[document.update .elements['MEMBER
      4'].selectedIndex].text;[color=blue]
      >
      > I get blah, blah ... 'is null or not an object'.
      >
      > I can see the object on the page and when I click on it I get the alert
      > message showing the name is "MEMBER4".
      >
      > I am stumped why I am getting this message. Something must not be right.
      > Could it be that it is not getting created in the form "update"? I need
      > to have it created there.
      >
      > Any help is appreciated.
      >
      > Mike[/color]


      Comment

      • Randy Webb

        #4
        Re: Is Null or Not an OBJECT

        Dominique wrote:
        [color=blue]
        > try document.all.it em("MEMBER4").v alue
        >
        > if this works, then it obviously isn't being created inside the form
        > "update"
        > :o)[/color]

        And then it only works in IE and perhaps Opera, since document.all is
        IE-ism.



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

        Comment

        • Dominique

          #5
          Re: Is Null or Not an OBJECT

          lol* i didn't give you that to solve yer problem, i gave it to you to check
          whether you CAN find the object

          try this, add an ID attibute to it and call it by the getElementById (not
          IE-ism) method

          "Randy Webb" <hikksnotathome @aol.com> wrote in message
          news:L5adnaxhDc KRMwfdRVn-sA@comcast.com. ..[color=blue]
          > Dominique wrote:
          >[color=green]
          > > try document.all.it em("MEMBER4").v alue
          > >
          > > if this works, then it obviously isn't being created inside the form
          > > "update"
          > > :o)[/color]
          >
          > And then it only works in IE and perhaps Opera, since document.all is
          > IE-ism.
          >
          >
          >
          > --
          > Randy
          > Chance Favors The Prepared Mind
          > comp.lang.javas cript FAQ - http://jibbering.com/faq/[/color]


          Comment

          • Randy Webb

            #6
            Re: Is Null or Not an OBJECT

            Dominique wrote:[color=blue]
            > lol* i didn't give you that to solve yer problem, i gave it to you to check
            > whether you CAN find the object
            >
            > try this, add an ID attibute to it and call it by the getElementById (not
            > IE-ism) method
            >
            > "Randy Webb" <hikksnotathome @aol.com> wrote in message
            > news:L5adnaxhDc KRMwfdRVn-sA@comcast.com. ..
            >[color=green]
            >>Dominique wrote:
            >>
            >>[color=darkred]
            >>>try document.all.it em("MEMBER4").v alue
            >>>
            >>>if this works, then it obviously isn't being created inside the form
            >>>"update"
            >>>:o)[/color]
            >>
            >>And then it only works in IE and perhaps Opera, since document.all is
            >>IE-ism.
            >>[/color][/color]

            Now you are making the mistake of assuming I am the one that posted the
            original question. Perhaps if you spent as much time trying to learn
            what you were doing, you would not be wasting as much time giving
            incompetent answers.


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

            Comment

            • Dominique

              #7
              Re: Is Null or Not an OBJECT

              oh fukkoff randy

              try giving a frikkin answer for once instead of giving snide remarks when
              we're trying to help people here.

              and sorry for not checking ur stoopid name in that last post, i'm busy
              actually HELPING PEOPLE in other groups.

              yer yapping and not helping, so just log off and go eat yer dinner, fukkin
              prick.

              and write better faq's on that crap website. learn some actual programming
              skills, not theory.


              "Randy Webb" <hikksnotathome @aol.com> wrote in message
              news:MaKdnXsBW5 NrMgfdRVn-gw@comcast.com. ..[color=blue]
              > Dominique wrote:[color=green]
              > > lol* i didn't give you that to solve yer problem, i gave it to you to[/color][/color]
              check[color=blue][color=green]
              > > whether you CAN find the object
              > >
              > > try this, add an ID attibute to it and call it by the getElementById[/color][/color]
              (not[color=blue][color=green]
              > > IE-ism) method
              > >
              > > "Randy Webb" <hikksnotathome @aol.com> wrote in message
              > > news:L5adnaxhDc KRMwfdRVn-sA@comcast.com. ..
              > >[color=darkred]
              > >>Dominique wrote:
              > >>
              > >>
              > >>>try document.all.it em("MEMBER4").v alue
              > >>>
              > >>>if this works, then it obviously isn't being created inside the form
              > >>>"update"
              > >>>:o)
              > >>
              > >>And then it only works in IE and perhaps Opera, since document.all is
              > >>IE-ism.
              > >>[/color][/color]
              >
              > Now you are making the mistake of assuming I am the one that posted the
              > original question. Perhaps if you spent as much time trying to learn
              > what you were doing, you would not be wasting as much time giving
              > incompetent answers.
              >
              >
              > --
              > Randy
              > Chance Favors The Prepared Mind
              > comp.lang.javas cript FAQ - http://jibbering.com/faq/[/color]


              Comment

              • Michael Hill

                #8
                Re: Is Null or Not an OBJECT



                Dominique wrote:[color=blue]
                >
                > lol* i didn't give you that to solve yer problem, i gave it to you to check
                > whether you CAN find the object
                >
                > try this, add an ID attibute to it and call it by the getElementById (not
                > IE-ism) method
                >[/color]

                When I changed this:

                mySELECT.name = "MEMBER" + j;

                to this:

                mySELECT.id = mySELECT.name = "MEMBER" + j;

                if worked fine.

                Thanks for the reminder.

                Mike

                Comment

                Working...