Saul wrote:
thanks for your replies...
Please quote the relevant parts of what you are replying to.
ds is a dataset coming from an Ajax call and roottype is an element of
this set... I am sure the Ajax call is not the issue(since the data is
obtained and rendered correctly) and this is why I focused in the
javascript part to find the problem.
I'll guess that -ds.Tables[0].Rows- is referring to your XML structure,
not the HTMLElement structure suggested by the names you've used.
The elements are createed correctly when I loop thru the array. The
radio buttons are there and are visible inside the div tag "td_company "
The issue arises when trying to reference the element "company" which
is the name given to all the radio buttons created dynamically.
Exactly. IE has trouble with the name attribute of elements added
dynamically - from Microsoft's documentation:
"The NAME attribute cannot be set at run time on elements
dynamically created with the createElement method. To create
an element with a name attribute, include the attribute and
value when using the createElement method."
<URL:http://msdn.microsoft. com/workshop/author/dhtml/reference/properties/...>
Read the thread I suggested provides 2 work-arounds, here it is again;
<URL:http://groups.google.c o.uk/group/comp.lang.javas cript/browse_frm/thread/db95b9f62035bee 6/a86500f9f588024 6?q=name+create Element&rnum=2# a86500f9f588024 6>
[...]
I tried the different recommendations above, but still get the same
issue! - Any other suggestions
Try one of the methods in the suggested thread. Here's mine, I'm sure
you can adapt it to your circumstance:
<script type="text/javascript">
function addRadios(form, grpName, num)
{
var oRadio, e;
var dom = true;
for (var i=0; i<num; ++i){
if (dom){
// Create radio button, give it a name and add to form
oRadio = document.create Element('input' );
oRadio.name = grpName;
form.appendChil d(oRadio);
// Test if can access radio button group
// If not, remove element and set dom
if ( 0 == i && !document.getEl ementsByName(gr pName).length){
dom = false;
form.removeChil d(oRadio);
}
}
// If dom set to false, use IE method to add element
if (!dom){
try {
oRadio = document.create Element('<input type="radio"'
+ ' name="' + grpName + '">');
form.appendChil d(oRadio);
} catch (e){ e = true;}
// If got to here and no error, add attributes to element
// and element to document
}
if (!e){
oRadio.type = 'radio';
oRadio.onclick = rbClicked;
oRadio.value = grpName + ' ' + i;
form.appendChil d(document.crea teTextNode('rad-' + i));
form.appendChil d(document.crea teElement('br') );
}
}
}
// A play onclick function to show name is set
function rbClicked(){
alert('Clicked me!'
+ '\nName: ' + this.name
+ '\nValue: ' + this.value);
}
</script>
<form action="" name="aFrom"><d iv>
<input type="button" value="Add radios"
onclick="addRad ios(this.form, 'rBtnGrp', 4);"><br>
<input type="button" value="Click second radio"
onclick="
alert('There are ' + document.getEle mentsByName('rB tnGrp').length
+ ' radio buttons');
this.form.rBtnG rp[1].click();
"><br>
</div></form>
--
Rob