我有一个父网页,其中包含客户#和名称搜索。如果您手动输入新客户#,则可以提交它以保存数据。如果我在名称搜索中输入一个值,它将通过javascript window.open启动第二个弹出页面并清除几个输入(稍后重新填充)。
function displayLookupWindow() {
// Launch the popup
newWindow=window.open('../administration/ad_custlookup.asp?userid=<%=user_id%>&company_nbr='+document.mainForm.txtCompany.value+'&guid=<%=GUID%>&lookup='+document.mainForm.customer_lookup.value,'customerLookupWindow','toolbar=no,location=no,scrollbars=yes,width=520,height=650');
// Clear the values in the parent screen
// This must come AFTER the window.open command
// This will execute as the window.open is also executing!
document.getElementById("txtCustomer").value = "";
document.getElementById("customer_lookup").value = "";
document.getElementById("txtCustName").value = "";
newWindow.focus();
}
弹出式网页构建一个包含父页面所需字符串的客户列表。当用户点击所需的客户时,该客户#将被传递回父网页,并且弹出网页将关闭:
function SetName(CustNo) {
if (window.opener != null && !window.opener.closed) {
// txtCustomer is the name of the id on the parent page.
// This is how we pass the value back to the parent page.
var txtCustomer = window.opener.document.getElementById("txtCustomer");
txtCustomer.value = document.getElementById(CustNo).value;
var txtCustChanged = window.opener.document.getElementById("txtCustChanged");
txtCustChanged.value = "Y";
}
window.close();
}
这样可以在父页面上用所需的值清晰地填充客户#输入。
如何强制它提交生成的客户编号(就像他们手动输入了值一样)? onchange不起作用,因为用户没有输入更改(它由javascript填充)。