与ASP中的document.form.submit()相关的问题

问题描述:

网页上有3个按钮。在点击每个按钮时,一个相同的弹出窗口(比如window1)打开。现在在这个弹出窗口(window1)上还有另一个按钮,它进一步打开到另一个弹出窗口(比如window2)。在从'window2'中选择某个值时,该值将被传递到'window1'上。有一个“查找”链路上的“窗口1”,它调用javascript函数“点击()”:与ASP中的document.form.submit()相关的问题

<head> 
<% 
Dim command 
command = Request.Form("hid"); 
Response.Write(“Value” & command); -- The value is not printed (Reason found after 
                analysis that may be because the form is not submitted 
                successfully) 
%> 

function clicked() 
{ 
document.form.hid.value='FIND'; 
alert("before");    -- This message box appears 
**document.form.submit();** -- after a lot of analysis the conclusion is that 
            this submit statement stops working (as on the status 
            bar 'Opening https:.....File1.asp?form=...' is not 
            displayed when 'after' message box appears 
alert("after");    -- This message box appears 
} 

<body.......> 
<% if command = "FIND" then 
Response.Write ("Inside Find"); -- This message is not printed. 
    // some functonality 

%> 
<form ....> 

<input type="hidden" name="hid" value=""> 

</form> 
</body> 

这充分代码工作正常,我的机器上。但是,在客户端运行时,此代码无法正常工作,尽管正在访问相同的服务器和相同的已部署应用程序。没有特定的顺序/场景,但例如。 当说button1 clicked-> window1打开 - > window2打开 - > value selected->返回到window1->点击Find->点击Ok->返回主页面。 然后为第三个按钮重复相同的场景。 (直到现在'查找'链接工作正常)。 现在重复第二个按钮相同的情况下,这里'后'的消息,但'内部查找'不打印!

+1

欢迎来到SO。你能检查Firefox脚本控制台的错误吗?由于这与ASP无关,您可以将实际生成的代码发布到浏览器中吗? – 2010-02-20 08:45:23

document对象没有form属性。

该代码仅适用于表单上具有属性name="form"且只有在页面上具有该名称的单个表单的情况。这是表单的错误名称,因为DOM中还有其他对象实际上具有form属性(即表单中的字段)。

您应该为表单指定一个明确的名称,并使用document.forms集合来访问表单,而不是依赖于将表单添加到文档名称空间。