I'm building a cross-browser XML dataisland.
This code works perfectly in mozilla, but i have problems with explorer.
it tells me that:
"diXML.getElementsByTagName(..).0 is null or not an object"
if i change my custom xml dataisland using <xml id="dataisland"></xml>
instead of the <div id="dataisland" ...> it shows a "type mismatch" error.
I have no problem accesing to the <di> tags inside the <table
id="dataisland_table">, so i can't see why i can't access them on the <div>.
Here is the code:
<script>
diFirstNode="di";
diItemNode="test";
function diXMLEdit (theForm,dI) {
diXML=document.getElementById(dI);
diForm=document.forms[dI+'_form'];
xmlElem=document.createElement(diItemNode);
for (i=0;i<theForm.elements.length;i++) {
if (theForm.elements[i].type!="button") {
if (diForm.dirow.value=="") {
xmlNode=document.createElement(theForm.elements[i].name);
xmlNode.innerHTML=theForm.elements[i].value;
xmlElem.appendChild(xmlNode);
} else {
}
}
}
if (diForm.dirow.value=="") {
diXML.getElementsByTagName(diFirstNode)[0].appendChild(xmlElem);
} else {
}
//diPopulate(theForm,dI);
}
</script>
<form name="dataisland_form">
<input type="hidden" name="dirow">
</form>
<div id="dataisland" style="display:none">
<di></di>
</div>
<table id="dataisland_table">
<tr id="dataisland_header">
<th>aa</th>
<th>bb</th>
<th>cc</th>
</tr>
<tr id="dataisland_schema" style="display:none">
<td><di field="aa"></di></td>
<td><di field="bb"></di></td>
<td><di field="cc"></di></td>
</tr>
</table>
<form name="myform">
<br><input type="text" name="aa">
<br><input type="text" name="bb">
<br><input type="text" name="cc">
<br><input type="button" value="go!"
onClick="diXMLEdit(document.myform,'dataisland')">
</form>