在表单提交之前运行JavaScript [英] Run JavaScript before Form Submits

查看:75
本文介绍了在表单提交之前运行JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何在将表单提交回

服务器之前运行java脚本函数。

我希望如何do有一个上传表单,当用户点击提交

按钮时,javascript函数打开第二个窗口,之后应该运行按钮

onclick事件。


这是否可行。

Hi
How can I run a java script function before a form is submited back to the
server.
What I wish to do is have a upload form that when a user clicks the submit
button a javascript function opens a second window after this the buttons
onclick event should be run.

Is any of this possible.

推荐答案

使用常规HTML而不是使用表单上的提交按钮按钮

上面有一个调用函数的onClick事件处理程序。


在该函数中,做任何你喜欢的事情,当你完成时调用

formName.submit()

" Kenneth Keeley" <柯******* @ hotmail.com.nowhere>在消息中写道

新闻:uI ************* @ tk2msftngp13.phx.gbl ...
Instead of using a submit button on your form, use a regular HTML button
that has an onClick event handler on it that calls a function.

In that function, do whatever you like and when you are done invoke
formName.submit()
"Kenneth Keeley" <ke*******@hotmail.com.nowhere> wrote in message
news:uI*************@tk2msftngp13.phx.gbl...

如何我可以运行一个java脚本函数,然后将表单提交回
服务器。
我希望有一个上传表单,当用户点击提交
按钮时,javascript函数打开第二个窗口后,应该运行按钮
onclick事件。

这是否可能。
Hi
How can I run a java script function before a form is submited back to the server.
What I wish to do is have a upload form that when a user clicks the submit
button a javascript function opens a second window after this the buttons
onclick event should be run.

Is any of this possible.



好的,

但是需要什么Serverside代码才能确保按下提交按钮

而不是清除或浏览器刷新按钮。


" Scott M." < S - *** @ badspamsnet.net>在消息中写道

news:eN ************** @ TK2MSFTNGP11.phx.gbl ...
Ok then,
But what Serverside code is required to make sure the submit button was
pressed and not a clear or browser refresh button.

"Scott M." <s-***@badspamsnet.net> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
而不是使用提交你的表单上的按钮,使用一个常规的HTML按钮
,它上面有一个调用函数的onClick事件处理程序。

在该函数中,做任何你喜欢的事情,当你完成调用
formName.submit()
Instead of using a submit button on your form, use a regular HTML button
that has an onClick event handler on it that calls a function.

In that function, do whatever you like and when you are done invoke
formName.submit()



调用javascript函数然后返回true。

表单将照常提交。

例如

myButton.Attributes.add(" onclick"," doThisFirst();");


页面


< script>

函数doThisFirst(){

alert(''你好'');

返回true;

}

< / script>

" Kenneth Keeley" ; <柯******* @ hotmail.com.nowhere>在消息中写道

新闻:uI ************* @ tk2msftngp13.phx.gbl ...
call the javascript function and then return true.
the form will be submitted as normal.
eg
myButton.Attributes.add("onclick","doThisFirst();" );

on the page

<script>
function doThisFirst() {
alert(''hello'');
return true;
}
</script>
"Kenneth Keeley" <ke*******@hotmail.com.nowhere> wrote in message
news:uI*************@tk2msftngp13.phx.gbl...

如何我可以运行一个java脚本函数,然后将表单提交回
服务器。
我希望有一个上传表单,当用户点击提交
按钮时,javascript函数打开第二个窗口后,应该运行按钮
onclick事件。

这是否可能。
Hi
How can I run a java script function before a form is submited back to the server.
What I wish to do is have a upload form that when a user clicks the submit
button a javascript function opens a second window after this the buttons
onclick event should be run.

Is any of this possible.



这篇关于在表单提交之前运行JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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