Jayakeerthi
02-13-2006, 04:37 PM
Hi everybody,
me facing issue in cross browser like the below code gives firstChild has no properties in Mozilla.
and no object found in IE browser...
i have tried..... sampleXML.item(k).firstChild.nodeValue;
sampleXML.item(k).firstChild.firstChild.nodeValue;
sampleXML.item(k).firstChild.nodeValue;
sampleXML.item(k).childNodes[0].childNodes[0].nodeValue;
sampleXML.item(k).childNodes[1].childNodes[0].nodeValue;
but nothing worked for me......
could anyOne helpme out in fixing this issue....
function selectProjectsForSurvey(){
// IE5.2 on Mac OSX doesn't support ActiveXObject
// So Dom Parser is used to parse, on Mozilla browser
if (document.implementation.createDocument)
{
// Mozilla, create a new DOMParser
parser = new DOMParser();
var xmlDoc = parser.parseFromString(document.forms[0].projectSurveyMappings.value, "text/xml");
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(document.forms[0].projectSurveyMappings.value);
}
var selectedProjectId =
document.forms[0].projectId.options[document.forms[0].projectId.selectedIndex].value;
if(selectedProjectId < 0){
alert("Inside added if...");
return " ";
}
var allowNext = false;
var projectXML = xmlDoc.getElementsByTagName("PROJECT");
var surveyXML;
var sampleXML;
for (i=0; i < projectXML.length; i++)
{
if (projectXML.item(i).getAttribute('id') == selectedProjectId)
{
surveyXML = projectXML.item(i).getElementsByTagName("SURVEY");
// Remove all the surveys from the list(associated with previous project)
document.forms[0].dataCollectionId.length = 0;
for (j=0; j < surveyXML.length; j++)
{
allowNext = true;
var opt = new Option();
opt.value = surveyXML.item(j).getAttribute("id");
//Line Modified to fix the Mac OSX issue
opt.text = sampleXML.item(k).firstChild.childNodes[1].childNodes[0].nodeValue;
//the above line has error: firstChild has no properties
document.forms[0].dataCollectionId[j] = opt;
}
sampleXML = projectXML.item(i).getElementsByTagName("SAMPLE");
document.forms[0].sampleId[0].length = 0;
for (k=0; k < sampleXML.length; k++)
{
var opt = new Option();
opt.value = sampleXML.item(k).getAttribute("id");
//Line Modified to fix the Mac OSX issue
//objXML.text doexn't support on mozilla.
opt.text = sampleXML.item(k).firstChild.childNodes[1].childNodes[0].nodeValue; document.forms[0].sampleId[0][k] = opt;
}
}
}
if (allowNext == true)
document.forms[0].next.disabled = false;
else
document.forms[0].next.disabled = true;
//document.forms[0].submit();
}
function onloadForSurvey()
{
selectProjectsForSurvey();
if (document.forms[0].dataCollectionId)
{
if (document.forms[0].dataCollectionId.length == 0)
document.forms[0].next.disabled = true;
else
document.forms[0].next.disabled = false;
}
}
thanks in advance
Keerthi
me facing issue in cross browser like the below code gives firstChild has no properties in Mozilla.
and no object found in IE browser...
i have tried..... sampleXML.item(k).firstChild.nodeValue;
sampleXML.item(k).firstChild.firstChild.nodeValue;
sampleXML.item(k).firstChild.nodeValue;
sampleXML.item(k).childNodes[0].childNodes[0].nodeValue;
sampleXML.item(k).childNodes[1].childNodes[0].nodeValue;
but nothing worked for me......
could anyOne helpme out in fixing this issue....
function selectProjectsForSurvey(){
// IE5.2 on Mac OSX doesn't support ActiveXObject
// So Dom Parser is used to parse, on Mozilla browser
if (document.implementation.createDocument)
{
// Mozilla, create a new DOMParser
parser = new DOMParser();
var xmlDoc = parser.parseFromString(document.forms[0].projectSurveyMappings.value, "text/xml");
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(document.forms[0].projectSurveyMappings.value);
}
var selectedProjectId =
document.forms[0].projectId.options[document.forms[0].projectId.selectedIndex].value;
if(selectedProjectId < 0){
alert("Inside added if...");
return " ";
}
var allowNext = false;
var projectXML = xmlDoc.getElementsByTagName("PROJECT");
var surveyXML;
var sampleXML;
for (i=0; i < projectXML.length; i++)
{
if (projectXML.item(i).getAttribute('id') == selectedProjectId)
{
surveyXML = projectXML.item(i).getElementsByTagName("SURVEY");
// Remove all the surveys from the list(associated with previous project)
document.forms[0].dataCollectionId.length = 0;
for (j=0; j < surveyXML.length; j++)
{
allowNext = true;
var opt = new Option();
opt.value = surveyXML.item(j).getAttribute("id");
//Line Modified to fix the Mac OSX issue
opt.text = sampleXML.item(k).firstChild.childNodes[1].childNodes[0].nodeValue;
//the above line has error: firstChild has no properties
document.forms[0].dataCollectionId[j] = opt;
}
sampleXML = projectXML.item(i).getElementsByTagName("SAMPLE");
document.forms[0].sampleId[0].length = 0;
for (k=0; k < sampleXML.length; k++)
{
var opt = new Option();
opt.value = sampleXML.item(k).getAttribute("id");
//Line Modified to fix the Mac OSX issue
//objXML.text doexn't support on mozilla.
opt.text = sampleXML.item(k).firstChild.childNodes[1].childNodes[0].nodeValue; document.forms[0].sampleId[0][k] = opt;
}
}
}
if (allowNext == true)
document.forms[0].next.disabled = false;
else
document.forms[0].next.disabled = true;
//document.forms[0].submit();
}
function onloadForSurvey()
{
selectProjectsForSurvey();
if (document.forms[0].dataCollectionId)
{
if (document.forms[0].dataCollectionId.length == 0)
document.forms[0].next.disabled = true;
else
document.forms[0].next.disabled = false;
}
}
thanks in advance
Keerthi