mozilla not recognising childnodes-getting console error
-
Dear sir, I have created controls dynamically and the controls are inside the table and the table inside the div.Im getting error in mozilla browser.. The sample html generated code is shown below <div id=divall runat="server">
sdfssdf
<select id=dd1> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> </select>
sdfssdf
<select id=dd1> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> </select>
sdfssdf
<select id=dd1> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> </select>
I access the value as below var divall = document.getElementById('divall'); //for getting all the controls inside the div var allcntr = divall.childNodes[0].childNodes[0].childNodes; for(var i=0;i<allcntr.length;i++)> { //for getting all the dropdownlist's value inside the table var cmball=divall.childNodes[0].childNodes[0].childNodes[i].getElementsByTagName('OPTION'); for(var j=0;j<cmball.length;j++)> { if(cmball[j].selected) { //some code } } } // divall.childNodes[0].childNodes[0].childNodes; The above code is working 5n in IE but not in mozilla. Is there any common code(compatible to all browsers mainly IE & Mozilla) to access the childnodes? Thanx for your help in advance..
T.Balaji
-
Dear sir, I have created controls dynamically and the controls are inside the table and the table inside the div.Im getting error in mozilla browser.. The sample html generated code is shown below <div id=divall runat="server">
sdfssdf
<select id=dd1> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> </select>
sdfssdf
<select id=dd1> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> </select>
sdfssdf
<select id=dd1> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> </select>
I access the value as below var divall = document.getElementById('divall'); //for getting all the controls inside the div var allcntr = divall.childNodes[0].childNodes[0].childNodes; for(var i=0;i<allcntr.length;i++)> { //for getting all the dropdownlist's value inside the table var cmball=divall.childNodes[0].childNodes[0].childNodes[i].getElementsByTagName('OPTION'); for(var j=0;j<cmball.length;j++)> { if(cmball[j].selected) { //some code } } } // divall.childNodes[0].childNodes[0].childNodes; The above code is working 5n in IE but not in mozilla. Is there any common code(compatible to all browsers mainly IE & Mozilla) to access the childnodes? Thanx for your help in advance..
T.Balaji
And this has what to do with the .NET Framework?? Ask this in the Web Developement forum.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
Dear sir, I have created controls dynamically and the controls are inside the table and the table inside the div.Im getting error in mozilla browser.. The sample html generated code is shown below <div id=divall runat="server">
sdfssdf
<select id=dd1> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> </select>
sdfssdf
<select id=dd1> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> </select>
sdfssdf
<select id=dd1> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> <option value="1">sdfsd</option> </select>
I access the value as below var divall = document.getElementById('divall'); //for getting all the controls inside the div var allcntr = divall.childNodes[0].childNodes[0].childNodes; for(var i=0;i<allcntr.length;i++)> { //for getting all the dropdownlist's value inside the table var cmball=divall.childNodes[0].childNodes[0].childNodes[i].getElementsByTagName('OPTION'); for(var j=0;j<cmball.length;j++)> { if(cmball[j].selected) { //some code } } } // divall.childNodes[0].childNodes[0].childNodes; The above code is working 5n in IE but not in mozilla. Is there any common code(compatible to all browsers mainly IE & Mozilla) to access the childnodes? Thanx for your help in advance..
T.Balaji
Well i had read in the w3schools.com that there is a small issue in accessing the childnodes.
balaji.t wrote:
divall.childNodes[0].childNodes[0].childNodes;
This works fine in IE but not in Firefox. The reason which i am not completely sure is that IE accesses with '0' index and '1' in Firefox. So just try by using 1 instead of 0 for accessing.