jQuery-在提交时动态构建表单操作? [英] Jquery - Dynamically build form action on submit?

查看:94
本文介绍了jQuery-在提交时动态构建表单操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户单击提交"按钮时,我试图构建HTML表单的动作.

I'm trying to have the action of a HTML form built when the user clicks the submit button.

因此,用户填写表单,单击提交,然后构建操作,然后实际提交.原因是因为表单上有很多选项,这些选项将传递给脚本.

So the user fills in a form, clicks submit, then the action gets built then it actually gets submitted. The reason being is because the form has a load of options on it which will be passed to a script.

我将如何使用Jquery做到这一点?

How would I go about doing this with Jquery?

推荐答案

未经测试,但这至少应该可以帮助您:

Untested, but this should at least get you on your way:

$('#myForm').submit(function (event)
{
    var action = '';
    // compute action here...
    $(this).attr('action', action);
});

这篇关于jQuery-在提交时动态构建表单操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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