Connecting Tech Pros Worldwide Forums | Help | Site Map

Is Null or Not an OBJECT

Michael Hill
Guest
 
Posts: n/a
#1: Jul 23 '05
I created this select dynamically in a page like:

var j=4;
mySELECT = document.createElement("SELECT");
mySELECT.name = "MEMBER" + j;
mySELECT.onclick = function (evt) { alert(this.name); }
myOPTION = document.createElement("OPTION");
myOPTION.value="1";
myTEXT=document.createTextNode("first");
myOPTION.appendChild(myTEXT);
mySELECT.appendChild(myOPTION);
myOPTION = document.createElement("OPTION");
myOPTION.value="2";
myOPTION.selected="true";
myTEXT=document.createTextNode("second");
myOPTION.appendChild(myTEXT);
mySELECT.appendChild(myOPTION);
myTD.appendChild(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
Guest
 
Posts: n/a
#2: Jul 23 '05

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.....
Dominique
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Is Null or Not an OBJECT


try document.all.item("MEMBER4").value

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

"Michael Hill" <hillmw@ram.lmtas.lmco.com> wrote in message
news:409A68E6.2808E149@ram.lmtas.lmco.com...[color=blue]
> I created this select dynamically in a page like:
>
> var j=4;
> mySELECT = document.createElement("SELECT");
> mySELECT.name = "MEMBER" + j;
> mySELECT.onclick = function (evt) { alert(this.name); }
> myOPTION = document.createElement("OPTION");
> myOPTION.value="1";
> myTEXT=document.createTextNode("first");
> myOPTION.appendChild(myTEXT);
> mySELECT.appendChild(myOPTION);
> myOPTION = document.createElement("OPTION");
> myOPTION.value="2";
> myOPTION.selected="true";
> myTEXT=document.createTextNode("second");
> myOPTION.appendChild(myTEXT);
> mySELECT.appendChild(myOPTION);
> myTD.appendChild(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]


Randy Webb
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Is Null or Not an OBJECT


Dominique wrote:
[color=blue]
> try document.all.item("MEMBER4").value
>
> 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.javascript FAQ - http://jibbering.com/faq/
Dominique
Guest
 
Posts: n/a
#5: Jul 23 '05

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:L5adnaxhDcKRMwfdRVn-sA@comcast.com...[color=blue]
> Dominique wrote:
>[color=green]
> > try document.all.item("MEMBER4").value
> >
> > 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.javascript FAQ - http://jibbering.com/faq/[/color]


Randy Webb
Guest
 
Posts: n/a
#6: Jul 23 '05

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:L5adnaxhDcKRMwfdRVn-sA@comcast.com...
>[color=green]
>>Dominique wrote:
>>
>>[color=darkred]
>>>try document.all.item("MEMBER4").value
>>>
>>>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.javascript FAQ - http://jibbering.com/faq/
Dominique
Guest
 
Posts: n/a
#7: Jul 23 '05

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:MaKdnXsBW5NrMgfdRVn-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:L5adnaxhDcKRMwfdRVn-sA@comcast.com...
> >[color=darkred]
> >>Dominique wrote:
> >>
> >>
> >>>try document.all.item("MEMBER4").value
> >>>
> >>>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.javascript FAQ - http://jibbering.com/faq/[/color]


Michael Hill
Guest
 
Posts: n/a
#8: Jul 23 '05

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
Closed Thread