M
Michael Hill
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
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