在javascript中提交() [英] Submit() in javascript

查看:71
本文介绍了在javascript中提交()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



是否可以将page1的表单值转换为page2。我知道提交按钮和提交功能,但当我在Request.form(FieldName)的帮助下尝试获取第2页中的值时,它给出了错误:请求未定义。

任何人都可以帮我这个。

我的代码是这样的:

Page1:

in html:

[HTML]< INPUT id =" FieldName"最大长度= QUOT 35 QUOT; name =" FieldName">

< input id =" Button1"的onclick = QUOT;的JavaScript的 的:提交()"类型= QUOT按钮"值= QUOT;继续] name =" Button1">

[/ HTML]

javascript函数是:

Hi,
Is it possible to get the page1''s form values to page2. I know about submit button and submit function but when I am trying to get the values in page 2 with the help of Request.form("FieldName") it gives me error: Request is undefined.
Can anyone help me with this.
My code is something like this:
Page1:
in html:
[HTML]<INPUT id="FieldName" maxLength="35" name="FieldName">
<input id="Button1" onclick="javascript:Submit()" type="button" value="Continue" name="Button1">
[/HTML]
the javascript function is:

展开 | 选择 | Wrap | 行号

推荐答案

如果你正在提交,不要设置location.href。将表单的action属性设置为此位置。
Don''t set the location.href if you''re submitting. Set the action property of the form instead to this location.


感谢回复,

正如您设置的那样,我也试过了。如果我的表格是

< form id =" frm1"名称= QUOT; Frm1中"行动= QUOT; page2.aspx"方法= QUOT;交" runat =" server">


和按钮是


< input id =" Button1"的onclick = QUOT;的JavaScript的 的:提交()"类型= QUOT按钮"值= QUOT;继续] name =" Button1">


和javascript是

document.forms [0] .submit();


它提交表格但不会转到下一页。


等待你的回复,

谢谢。
Thanks for the Reply,
As you set I tried that also. If my form is
<form id="frm1" name="frm1" action="page2.aspx" method="post" runat="server">

and the button is

<input id="Button1" onclick="javascript:Submit()" type="button" value="Continue" name="Button1">

and javascript is
document.forms[0].submit();

It submits the form but wont forward to the next page.

Waiting for your reply,
Thanks.


如果您正在提交,请不要​​设置location.href。将表单的action属性设置为此位置。
Don''t set the location.href if you''re submitting. Set the action property of the form instead to this location.


在您的代码中,您将表单提交到 page2.aspx ,然后将其重定向到同一页面,即。 page2.aspx 。如果是这种情况,那么你不需要重定向它。


但是如果你需要将它重定向到其他页面,那么在处理 page2.aspx ,将其添加到ASP代码的末尾...
In your code, you are submitting the form to page2.aspx and then redirecting it to the same page, ie. page2.aspx. If that is the case, then you don''t need to redirect it.

But if you need to redirect it to some other page, then after processing the form data in page2.aspx, add this to the end of your ASP code...
展开 | 选择 | Wrap | 行号


这篇关于在javascript中提交()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆