Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/418.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
与Javascript相关的选择填充了不在Chrome或IE中工作的xml(无兼容性视图)_Javascript_Jquery_Html_Xml_Google Chrome - Fatal编程技术网

与Javascript相关的选择填充了不在Chrome或IE中工作的xml(无兼容性视图)

与Javascript相关的选择填充了不在Chrome或IE中工作的xml(无兼容性视图),javascript,jquery,html,xml,google-chrome,Javascript,Jquery,Html,Xml,Google Chrome,我在工作中有一个多年前编写的网页,当我们尝试更新它以在更现代的浏览器中使用时,它给了我一些问题 我在Chrome中遇到的错误是未捕获的TypeError:xml_map.namedRecordset不是函数 这导致我们无法填充选择框,因为它似乎在xml解析方面存在问题 选择框的javascript如下所示: <script language="JScript"> $(function() { var currentDate = new Date(); $('#dat

我在工作中有一个多年前编写的网页,当我们尝试更新它以在更现代的浏览器中使用时,它给了我一些问题

我在Chrome中遇到的错误是未捕获的TypeError:xml_map.namedRecordset不是函数

这导致我们无法填充选择框,因为它似乎在xml解析方面存在问题

选择框的javascript如下所示:

<script language="JScript">

$(function() {
    var currentDate = new Date();
    $('#datepicker1').datepicker({
        inline: true,
        showOtherMonths: true,
        dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
        dateFormat: 'dd/mm/yy'
    });
    $("#datepicker1").datepicker("setDate", "-30d");
});

$(function() {
    var currentDate = new Date();
    $('#datepicker2').datepicker({
        inline: true,
        showOtherMonths: true,
        dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
        dateFormat: 'dd/mm/yy'
    });
    $("#datepicker2").datepicker("setDate", currentDate);
});

//date_index_choice allows us to use Report_Date date index if it exists, otherwise we use Cypress date (Document Creation Time)
var date_index_choice = "[Document Creation Time]";

// Fill first drop down list when desired
function refill()
    {
    FillSortDropDownWithFields(queryform.dropdown1, xml_map.namedRecordset("", "category_list.category"));
    }

// Refill second drop down list when desired
function refill2(x)
    {
    dRecordSet=xml_map.namedRecordset("", "category_list.category");
    dRecordSet.MoveFirst();
    x = x - 1
    for (i=0; i<x; i++)
        {
        dRecordSet.MoveNext();
        }
    //"category_list.category.sub_category"
    FillSortDropDownWithFields2(queryform.dropdown2, xml_map.namedRecordset("", "category_list.category.sub_category"));
    }

//Refill dropdown menu
function refill3(x)
    {
    dRecordSet=xml_map.namedRecordset("", "category_list.category.sub_category");
    dRecordSet.MoveFirst();
    x = x - 1;
    for (i=0; i<x; i++)
        {
        dRecordSet.MoveNext();
        }
    //"category_list.category.sub_category"
    FillSortDropDownWithFields3(queryform.dropdown3, xml_map.namedRecordset("", "category_list.category.sub_category.report_name"));
    }

// Fill dropdown with field names from the ADO RecordSet
function FillSortDropDownWithFields(oDropDown, oRecordSet)
    {
    // Clear out the current drop down values
    //alert(oRecordSet.RecordCount);
    var record_length       = 0;

    for (i=0; i < oDropDown.options.length;i+1)
        {
        oDropDown.options[i]=null;
        }

    record_length       = oRecordSet.RecordCount + 1
    //Get to the first element of the dataset
    oRecordSet.MoveFirst();
    // add each of the elements in the dataset to the drop-down
    for (i=0; i < record_length; i++)
        {
        oField = oRecordSet.fields;
        //alert(oField(2).value);
        if(i == 0)
            oDropDown.options[i]=new Option("--Select--","--Slelct--")
        else
            oDropDown.options[i]=new Option(oField(1).value,oField(1).value)
        if(i > 0)
            oRecordSet.MoveNext(); 
        }
    }

function FillSortDropDownWithFields2(oDropDown, oRecordSet)
    {   
    // Clear out the current drop down values
    for (i=1; i<oDropDown.options.length;i+1)
        {
        oDropDown.options[i]=null;
        }

    //alert(oRecordSet.RecordCount);
    //Get to the first element of the dataset
    oRecordSet.MoveFirst();

    // add each of the elements in the dataset to the drop-down
    for (i = 1; i <= oRecordSet.RecordCount; i++)
        {
        oField = oRecordSet.fields;
        //alert(oField(4).value);
        oDropDown.options[i]=new Option(oField(1).value,oField(1).value)
        oRecordSet.MoveNext(); 
        }
    }

//Fills the thirs drop down menu  
function FillSortDropDownWithFields3(oDropDown, oRecordSet)
    {   
    // Clear out the current drop down values
    for (i=1; i < oDropDown.options.length;i+1)
        {
        oDropDown.options[i]=null;
        }

    //alert(oRecordSet.RecordCount);
    //Get to the first element of the dataset
    oRecordSet.MoveFirst();

    // add each of the elements in the dataset to the drop-down
    for (i = 1; i <= oRecordSet.RecordCount; i++)
        {
        oField = oRecordSet.fields;
        //alert(oField(0).value);
        oDropDown.options[i]=new Option(oField(0).value,oField(0).value)
        oRecordSet.MoveNext(); 
        }
    }

//Gets indexes from CYpress generated XML file
function load_indexes()
    {
    var report_name             = "";
    var rdm_group_size          = 0;
    var rdm_report_size         = 0;
    var rdm_inx_size            = 0;
    //var xmlDoc                    = new ActiveXObject("Microsoft.XMLDOM");
    var array_counter           = 0;
    var invalid_index_counter   = 0;
    var group_counter           = 0;
    var report_counter          = 0;
    var sub_report_counter      = 0;
    var index_list_counter      = 0;
    var index_counter           = 0;
    var index_name_array_counter= 0;
    var total_index_count       = 0;
    var index_name_array        = new Array();

    //xmlDoc.async="false";
    //xmlDoc.onreadystatechange=verify;

    //alert("Before XML Load");
    //xmlDoc.load("GR_Prd_DV1_rdm_groups.xml");
    xmlObj=xmlDoc.documentElement;
    /*
    if (xmlDoc.readyState != 4)
        {
        alert("XML file did not load");
        return;
        }   
    */
    //alert("After XML Load");

    //RDM Groups List
    //alert("Initial Tag:" + xmlObj.tagName);
    //alert("Report_list:" + xmlObj.childNodes(0).tagName);
    //alert("Group Length:" + xmlObj.childNodes(0).childNodes.length);
    //alert("Report Parameter:" + document.queryform.dropdown3.value);
    while (report_counter < xmlObj.childNodes(0).childNodes.length)
        {
        //alert("Report Names:" + xmlObj.childNodes(0).childNodes(report_counter).getAttribute("obj_name"));
        //Loop through RDM Groups
        //alert("Report Counter=" + report_counter);
        if(xmlObj.childNodes(0).childNodes(report_counter).getAttribute("obj_name") == document.queryform.dropdown3.value)
            {
            //alert("Reports:" + xmlObj.childNodes(0).childNodes(report_counter).tagName)
            //Sub Report Loop
            index_list_counter = 0;
            while(index_list_counter < xmlObj.childNodes(0).childNodes(report_counter).childNodes.length)
                {
                 if(xmlObj.childNodes(0).childNodes(report_counter).childNodes(index_list_counter).tagName == "index_list")
                    {
                    //alert("index_list:" + xmlObj.childNodes(0).childNodes(report_counter).childNodes(index_list_counter).tagName);    
                    //Loop through indexes
                    //index_counter = 0;
                    while(index_counter < xmlObj.childNodes(0).childNodes(report_counter).childNodes(index_list_counter).childNodes.length)
                        {
                        index_name_array[index_counter] = xmlObj.childNodes(0).childNodes(report_counter).childNodes(index_list_counter).childNodes(index_counter).getAttribute("obj_name");
                        total_index_count   = index_counter;
                        //alert("index name:" + xmlObj.childNodes(0).childNodes(report_counter).childNodes(index_list_counter).childNodes(index_counter).getAttribute("obj_name"));
                        index_counter = index_counter + 1;
                        }//end of looping through indexes
                    }//end of index_list (if)
                index_list_counter = index_list_counter + 1;
                }//End of index_list    
            }//End of Report Name Compare(if)
        report_counter = report_counter + 1;
        }//End of Looping though Groups

    //Clear out current index drop down values
        for (i=1;i<queryform.dropdown4.options.length;i+1)
            {
            //alert ("Clearing index:"+queryform.dropdown4.options[i])
            queryform.dropdown4.options[i] = null;
            }

    //Set date_index_choice to use Cypress date by default
    date_index_choice = "[Document Creation Time]";
    //alert("total_index_count(" + total_index_count + ")")
    while(array_counter <= total_index_count)
        {
        //alert("Adding Index:" + index_name_array[array_counter])
        //Add to indices to index list unless it is the generic date index, report ID or name, or old category index
        if (index_name_array[array_counter] != "Report_Date" && index_name_array[array_counter] != "Report ID" && index_name_array[array_counter] != "Report Category")
            queryform.dropdown4.options[array_counter + 1 - invalid_index_counter]=new Option(index_name_array[array_counter],index_name_array[array_counter])
            else 
                {
                //Use Report_Date for date search index if it exists
                if (index_name_array[array_counter] == "Report_Date")
                    date_index_choice = "[Report_Date]";
                invalid_index_counter = invalid_index_counter + 1;
                }
        array_counter = array_counter + 1;
        }
    //alert("end of Load Index Function");
    }


function reorder_date(string)
    {   
    year = string.substring(string.length-4);
    month = string.substring(0,string.indexOf("/"));
    day = string.substring(string.indexOf("/")+1,string.lastIndexOf("/"));
    next_string= year + "," + month + "," + day;
//  alert(next_string);
    return next_string;
    }
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@                                                                            @@
@@ Function:     submit_query                                                 @@
@@ Returns:      n/a                                                          @@
@@ Description:  prepares the form objects for query then submits query       @@
@@                                                                            @@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
function submit_query()
  {
 var querystring   =""; 


//Check that a report name is selected
 if (queryform.dropdown3.value == "")
    {
        alert("Please select a Category, Subcategory, and/or Report Name");
        return;
    } 

//Check for criteria value entered but index not selected
 if(queryform.dropdown4.value == "" && queryform.query_text.value !="") 
    {
    alert("Please select which Criteria to use or clear the Criteria text");
    return;
    }

//Check for criteria index select but no value entered
 if(queryform.dropdown4.value != "" && queryform.query_text.value =="") 
    {
    alert("Please enter Criteria text or clear Criteria selection");
    return;
    }

//Check for from date not entered but to date entered
 if(queryform.date1.value == "" && queryform.date2.value != "") 
    {
    alert("You must enter a beginning date");
    return;
    }

if(queryform.dropdown3.value == "All Reports" && queryform.dropdown4.value == "")
    {
    alert("This search requires Criteria to be entered");
    return;
    }

 if(queryform.dropdown3.value != "All Reports")
    querystring  = "[Document Distribution Report]=\"" + queryform.dropdown3.value + "\"";


 if(queryform.dropdown4.value != "")
    {
    if(queryform.dropdown3.value != "All Reports")
        querystring = querystring + " and ";

//logic for using numeric indices
    if(queryform.dropdown4.value != "AP Acct Nbr" && queryform.dropdown4.value != "Branch Nbr" && queryform.dropdown4.value != "Company Nbr" && queryform.dropdown4.value != "Employee Nbr" && queryform.dropdown4.value != "Tractor Nbr")
        querystring = querystring + "[" + queryform.dropdown4.value + "]=\"" +  queryform.query_text.value + "\""
        else querystring = querystring + "[" + queryform.dropdown4.value + "]=" +  queryform.query_text.value;
    }

 if(queryform.date1.value != "" && queryform.date2.value == "")
   querystring = querystring + " and "+date_index_choice+"=tstamp(" + reorder_date(queryform.date1.value) + ")";

 if(queryform.date1.value != "" && queryform.date2.value != "")
   querystring = querystring + " and "+date_index_choice+">=tstamp(" + reorder_date(queryform.date1.value) + ") and "+date_index_choice+"<=tstamp(" + reorder_date(queryform.date2.value) + ",23,59)";


//Check for null query string
 if(querystring == "") 
    {
    alert("This search requires Criteria and/or Date Range");
    return;
    }


  //alert(querystring); 
  //parent.document.frames(1).document.CypressQuery.DoQuery(querystring);
    top.open("http://mastodon.grhq.gfs.com:8080/DocumentViewer/Query.html?InitQuery="+querystring+"%20");
  }

function queryform_onsubmit()
  {
  submit_query();
  return(false);  
  }
</script>
html如下所示:

<body onLoad="refill();" bgcolor="#FFFFFF" align="center">
<!-- Include the XML files with the report list for the drop down  -->
<XML src="MapFile.xml" ID="xml_map"></XML>
<XML src="GFS_RDM_rpt_inx.xml" ID="xmlDoc"></XML>

<form LANGUAGE="JScript" ONSUBMIT="return queryform_onsubmit()" name="queryform">
<div id="header">
        <p>Cypress Web Query</p>
</div>
<div id="main">
<div id="container1">
<div id="categories">
    <p>*Category:&nbsp;
    <select onchange="refill2(this.options.selectedIndex)" name="dropdown1">
        <option selected>--Select--</option>
    </select>
    </p>
    <p>*Subcategory:&nbsp;
    <select onchange="refill3(this.options.selectedIndex)" name="dropdown2">
        <option selected>--Select--</option>
    </select>
    </p>
    <p>*Report Name:&nbsp;
    <select onchange="load_indexes()" name="dropdown3">
        <option selected>--Select--</option>
    </select>
    </p>
    <p style="color:#505050">Criteria:&nbsp;
    <select id="dropdown4" name="dropdown4">
        <option selected>--Select--</option>
    </select>
    <input class="formFIELD" size="20" id="query_text" name="query_text" type="text">
    </p>
    <p style="font-size: medium">*Required fields in RED</p>
</div>
</div>

<div id="container2">
<div id="reportdates">
    <p>Report Dates between
        <input class="formFIELD" value="" size="10" id="datepicker1" name="date1" type="text">
    </p>
    <p>and
        <input class="formFIELD" value="" size="10" id="datepicker2" name="date2" type="text">
    </p>
        <input value="Submit" name="Submit" type="submit">&nbsp;&nbsp;&nbsp;&nbsp;<input value="Reset" id="Reset5" type="reset" name="Reset">
</div>
</div>
</div>
</form>
</body>
xml文件非常大,因此这里有一节介绍结构:

    <?xml version="1.0" ?>
    <Map_File file_use= "Mapping file for page indexes">
                    <category_list>
                                    <category obj_name= "Accounts Payable">
                                                   <sub_category obj_name="1099 Reports">
                                                                    <report_name obj_name= "AP145"/>
                                                                    <report_name obj_name= "AP245"/>
                                                   </sub_category>
                                                   <sub_category obj_name="A/P Close Reports">
                                                                    <report_name obj_name= "AP136 1 Invc Accrual"/>
                                                                    <report_name obj_name= "AP136 28 Invc Accrual"/>
                                                                    <report_name obj_name= "AP136 61 Invc Accrual"/>
                                                                    <report_name obj_name= "AP136 999 Invc Accrual"/>
                                                                    <report_name obj_name= "AP175 28 Invc Dist Close"/>
                                                                    <report_name obj_name= "AP1751 Invc Dist Close"/>
                                                                    <report_name obj_name= "AP1751 Out of Balance"/>
                                                                    <report_name obj_name= "AP1751 Invc Accr Entries"/>
                                                                    <report_name obj_name= "AP17561"/>
                                                                    <report_name obj_name= "AP175999 Invc Dist Close"/>
                                                                    <report_name obj_name= "AP175999 Out of Balance"/>
                                                                    <report_name obj_name= "AP175999 Invc Accr Entries"/>
                                                                    <report_name obj_name= "AP230"/>
                                                                    <report_name obj_name= "AP23028"/>
                                                                    <report_name obj_name= "AP230TH1 Open Payables Rpt"/>
                                                                    <report_name obj_name= "AP230999 Open Payables Rpt"/>
                                                                    <report_name obj_name= "GP162 Cash Disc Alloc"/>
                                                                    <report_name obj_name= "GP16228 Cash Disc Alloc - CAN"/>
                                                                    <report_name obj_name= "GP16261 Cash Disc Alloc"/>
                                                                    <report_name obj_name= "GP162TH Cash Disc Alloc"/>
                                                   </sub_category>
                                </category>
                </category_list>
</Map_File>
我承认我不是一个网络开发者,我只是想让这个页面工作,因为它是我们的一个应用程序的界面。任何帮助都将不胜感激


谢谢

XML数据孤岛HTML中的XML标记仅受Internet Explorer支持。甚至微软也取消了对IE 10的支持:

这显然是很久以前的一些旧代码。在Chrome中出现此错误的原因是,Chrome以及所有现代浏览器都无法识别XML标记及其所有相关函数


很抱歉,您必须重写此代码以使用现代的、受支持的方法。

谢谢,似乎就是这样。我期待着杀死这一页,从灰烬中重新创造。不幸的是,在我们的应用程序升级上线日期之前,这是不可能的。像这样的问题有时让我对自己的职业选择产生疑问;创建这段代码的人显然只想到IE用户。