Hello,
This problem has been vexing me for many many hours. I would appreciate it if someone could help me out with this.
The goal I have is to set the values in the following form with values parsed out of the XML file, which I had just pulled down from the server. I have confirmed that the XML coming from the server is fine, the values are there and the form is there. Also, everything works just fine in Firefox. The problem is when I have to run it in the hunk of junk (IE6).
Here is the form that I need to populate:
Specimen ID : |
|
|
Report |
||
|
||
Client ID : |
|
|
Ref. No. : |
|
|
Agency Code : |
|
|
Requestor : |
|
|
Collector : |
|
|
Collection Date : |
|
|
Collection Time : |
|
|
Specimen Reason : |
|
|
Latest Order Comment : |
|
|
Admitted Drugs : |
|
|
Specimen Outcome : |
– OUTCOME – POSITIVE NEGATIVE PENDING REJECTED |
|
Here is a snippet of the javascript code I’m using to populate the form:
function loadSpecimenInfoForm(loader) {
console.debug(“loadSpecimenInfoForm( )”);
//var f = document.forms[‘specimenInfoForm’];
//var f = document.forms[‘specimenInfoForm’];
var f = document.getElementById(“specimenInfoForm”);
var s = “”;
var v = “”;
for(i = 0; i < f.elements.length; i++) {
s += “[” + i + “]” + f.elements[i].name + “,”;
v += f.elements[i].value + “,”;
}
console.debug(“f.elements.length=” + f.elements.length + " s=" + s + " v=" + v);
console.debug(“loading 0”);
idNode = loader.doXPath("/specimen/id/text()",null,null,“single”);
try {
var idNode_str = new String();
idNode_str = idNode.nodeValue;
console.debug("idnode = " + idNode_str);
f.elements[0].value = idNode_str;
console.debug(“did it?”);
} catch( e) {
console.debug(“ahh!!” + e);
}
During the troubleshooting process, I tried several ways of referencing the form (i.e. document.forms[‘specimenInfoForm’], document.forms[1], document.specimenInfoForm, etc). I eventually decided that the form able to be referenced ok in IE6 when my for loop showed me that everything is there:
for(i = 0; i < f.elements.length; i++) {
s += “[” + i + “]” + f.elements[i].name + “,”;
v += f.elements[i].value + “,”;
}
So I’ve eliminated that as being the problem. I also tried printing the value that I pull down from the doXPath, and it shows up just fine. I have tried just setting a value for the form element manually (i.e. f.elements[i].value = ‘test’ and that works fine too!
The error is only thrown when I try to copy the value I get from doXPath.nodeValue to the form element; in all of the ways I have tried referencing the form, I get [object Error] and no other pertinent information. But everything works just fine in FireFox, in all of the ways I have tried.
Any Ideas?
Thanks,
Chris