Click here to Skip to main content
15,905,148 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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">
<table cellpadding="0" border="0" id="tblall">
<tr>
<td><span id="lblas">sdfssdf</span></td>
<td>
<select id=dd1>
<option value="1">sdfsd</option>
<option value="1">sdfsd</option>
<option value="1">sdfsd</option>
<option value="1">sdfsd</option>
</select>
</td>
</tr>
<tr>
<td><span id="lblas">sdfssdf</span></td>
<td>
<select id=dd1>
<option value="1">sdfsd</option>
<option value="1">sdfsd</option>
<option value="1">sdfsd</option>
<option value="1">sdfsd</option>
</select>
</td>
</tr>

<tr>
<td><span id="lblas">sdfssdf</span></td>
<td>
<select id=dd1>
<option value="1">sdfsd</option>
<option value="1">sdfsd</option>
<option value="1">sdfsd</option>
<option value="1">sdfsd</option>
</select>
</td>
</tr>

</table>


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
}
}


}

//
<br />
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..

Is there any other alternate besides prototypes?
Posted
Updated 17-Nov-10 0:51am
v3

1 solution

My advice is to use some cross browser library.
I prefer Prototype others might say jQery or
whatever else libs hang around out there.
These libraries really take the pain out of
cross browser compatibility.

Sorry forgot the link to my favorite:
http://www.prototypejs.org/

Cheers

Manfred
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900