简体   繁体   English

序列号框不再自动填充

[英]Serial Number Box Wont Autofill Anymore

1 Last year, Chrome made updates that blocks certain javascript from working properly. 1去年,Chrome 进行了更新,阻止某些 javascript 正常工作。 I have this working in Internet Explorer but it doesn't work in Firefox, Edge, or Chrome.我有这个在 Internet Explorer 中工作,但它在 Firefox、Edge 或 Chrome 中不起作用。

When selecting a specific Part, which is checked in pcpSelect variable, the Serial number correlated to that part will automatically display in the text box.选择在PCPSELECT变量中检查的特定零件时,与该部分相关的序列号将自动显示在文本框中。 But it is getting blocked now and I am having issues getting the DOM to work properly now.但它现在被阻止了,我现在无法让 DOM 正常工作。 Does anyone have any suggestions?有没有人有什么建议? Here is a screenshot of the error after selecting part number from dropdown这是从下拉列表中选择零件编号后的错误截图

function fillSerial()
{
    var pcpSelect = document.frm_CreatePCP.PCP_ID.selectedIndex;
    var PCP = document.frm_CreatePCP.PCP_ID(pcpSelect).value;
    //alert(PCP);
    for (var i = 1; i < PCP_array.length; i++) 
    {
        if ( PCP == PCP_array[i] )
            {
            document.frm_CreatePCP.sn.value = Number(Serial_array[i]) +1;
            document.frm_CreatePCP.sn.refresh;
            document.frm_CreatePCP.part.value=PCP;
            //document.getElementById("openserial").onclick="javascript:void window.open('selectExistSerial.cfm?pcp_id='+PCP+','1351625603240','width=300,height=150,resizable=1,left=650,top=300');" ;
            document.getElementById("openserial").disabled = false;
            break;
            
            }
    }
}

function openSerialWindow()
{
    var pcpSelect = document.frm_CreatePCP.PCP_ID.selectedIndex;
    var PCP = document.frm_CreatePCP.PCP_ID(pcpSelect).value;
    if (PCP.length < 1) {
        alert ("Part is required");
        document.frm_CreatePCP.PCP_ID.focus();
        }
    else
    {
    //alert(PCP);
    //mywindow = window.open("'selectExistSerial.cfm?pcp_id='+PCP+','1351625603240','width=300,height=150,resizable=1,left=650,top=300'");
    mywindow = window.open('selectExistSerial.cfm?pcp_id='+PCP,'mywindow','width=650,height=350,resizable=1,left=650,top=300,scrollbars=1');
    }
}
<form action="man_insp_enter_serial.cfm" name="frm_CreatePCP" method="post" > <!-- changed name to id name="frm_CreatePCP" -->
    <input type="hidden" name="part" value="<cfoutput>#form.part#</cfoutput>">
    <table border="1" cellpadding="6" cellspacing="2" align="center" >
        <tr>
            <td align="center"  colspan="2" bgcolor="#CCCCCC"><div class="bluem" >Start Manual Inspection Template</div></td></tr>
        <tr>
            <td align="center"  >
                <b>Part:&nbsp;&nbsp;</b>
                <select name="PCP_ID" onchange="fillSerial();" >
                    <option value="">Choose One</option>
                    <SCRIPT language=JavaScript type="text/javascript">
                        var Serial_array = new Array();
                        var PCP_array = new Array();
                    </SCRIPT>               
                    <cfset j=1>
                    <cfoutput query="qryAporvedPCP">
                        <option value="#qryAporvedPCP.PCP_ID#" <cfif qryAporvedPCP.PCP_ID eq form.part> selected </cfif> >#qryAporvedPCP.PARTNUM#</option>
                        <SCRIPT language=JavaScript type= "text/javascript" >
                            Serial_array[#j#] = "#qryAporvedPCP.MAX_SERIAL#";
                            PCP_array[#j#] = "#qryAporvedPCP.PCP_ID#";
                        </SCRIPT>
                        <cfset j=j+1>
                        <!-- <cfset ary_PCP_ID = ListToArray( valueList(qryAporvedPCP.PCP_ID) ) >
                        <cfset ary_SERIAL = ListToArray( valueList(qryAporvedPCP.MAX_SERIAL) ) > -->
                        </cfoutput>
                </select>
                </td>
                <td >Serial Number: <input type="text" name="sn" size="7" maxlength="7" style="text-transform:uppercase; text-align:center; font-weight:bold" onkeypress="return isNumberDecKey(event);" value="" />&nbsp;<input type="button" name="openSerial" value ="S/N Used"  onclick="javascript: openSerialWindow()" ></td>
            <input type="hidden" name="freq" value="0"  />
            <input type="hidden" name="temp" value="68"  />
        </tr>
    </table>
</form>

I test your code and it shows error in all browsers including IE.我测试了您的代码,它在包括 IE 在内的所有浏览器中都显示错误。 I get the same error like the one in your screenshot.我收到与您的屏幕截图中相同的错误。 The error shows the code you get the <select> value in PCP is wrong.该错误显示您在PCP中获得<select>值的代码是错误的。 You can edit the code into document.frm_CreatePCP.PCP_ID[pcpSelect].value .您可以将代码编辑到document.frm_CreatePCP.PCP_ID[pcpSelect].value中。 Then it can get the value correctly and works in all browsers.然后它可以正确获取值并在所有浏览器中工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM