0

我试图弄清楚为什么我会收到错误:

"window.opener.document.aspnetForm.formType is null or not an object".

我通过 URL 字符串将父窗口中的值传递给弹出窗口(此子窗口是搜索表单)。此值是 SharePoint 表单字段的 ID(我需要这样做是有原因的,该值指示它是来自 newform 还是 editform)。我使用子窗口中的函数 (geturlvalue()) 从 url 字符串中获得的值声明变量 formType,

var formType = geturlvalue(name);

变量“formType”在子窗口中正常工作,在窗口打开器显示来自父窗口的正确值之前提醒它 ctl00_m_g_004d943c_bb99_4fba_bee5_68862443b98d_ctl00_ctl04_ctl18_ctl00_ctl00_ctl04_ctl00_ctl00_TextField

这是子窗口中的开瓶器:

window.opener.document.aspnetForm.formType.value = document.getElementById('Server').value;

开启者需要使用 ID 为 Server 的子窗口字段中的值填充父窗口中的输入字段。

有人知道为什么我在 formType 上收到错误吗?如果我添加ctl00_m_g_004d943c_bb99_4fba_bee5_68862443b98d_ctl00_ctl04_ctl18_ctl00_ctl00_ctl04_ctl00_ctl00_TextField到 opener 来代替 formType 它可以正常工作并填充父输入字段:

window.opener.document.aspnetForm.ctl00_m_g_004d943c_bb99_4fba_bee5_68862443b98d_ctl00_ctl04_ctl18_ctl00_ctl00_ctl04_ctl00_ctl00_TextField.value = document.getElementById('Server').value;

4

2 回答 2

2

看起来像是formType父窗口中元素的 ID,所以在这种情况下,您需要这样的代码:

window.opener.document.getElementById(formType).value = document.getElementById('Server').value;
于 2013-01-16T14:01:00.077 回答
0

不是很详细的问题,无论如何都要尝试。

我真的被你的台词弄糊涂了:

window.opener.document.aspnetForm.formType.value = document.getElementById('Server').value;

它是什么 ?

如果您想使用,请确保您的表单具有 name="aspnetForm"(不是 id):

window.opener.document.aspnetForm

如果您想使用,请确保您的表单元素具有 name="formType" (不是 id):

window.opener.document.aspnetForm.formType.value = ...

我想知道你如何期望 var formType 成为 window.opener.document 的一部分,但也许你已经在代码的其他地方定义了所有这些东西,所以也许你应该发布更多代码,让其他人了解你的程序中发生了什么.

于 2013-01-16T13:25:21.550 回答