请考虑以下形式:
<form action="/a" method="post">
<input name="x" type="text" onblur="myonblur(e)" />
<input name="y" type="text" />
<input name="submit" type="submit" value="Submit" />
</form>
Run Code Online (Sandbox Code Playgroud)
当焦点位于名为"x"的元素并且用户按下提交按钮时,onblur事件将触发,但不提交表单.如果我在表单中有onblur事件,有没有办法让提交按钮按预期工作?
我使用jquery的.submit()来拦截用户的提交事件,但是我发现了一个问题.
当用户单击提交按钮时,表单正常提交,但如果用户故意多次快速单击,则会多次提交,这将导致数据库中的重复数据.
这种问题的解决方案是什么?
更新:嗯,我看到一些建议说禁用提交按钮.这应该可以防止多次提交表单,但问题是我的页面中的表单元素没有刷新,如果我禁用它,用户将无法再提交它,禁用15秒可能会有效,但是这是解决这个问题的正确方法吗?
我正在为自己编写一个小网站,但在使用看似简单的一行代码时遇到了麻烦:
form action="send.php" method="post"
Run Code Online (Sandbox Code Playgroud)
此外,即使是一条简单的线form action="http://www.google.com">也行不通。这是我的代码:
<html>
<head>
<title>
AnonMail!
</title>
</head>
<body style="font-family:'Tahoma';>
<form action="send.php" method="post">
<label for="from">From: </label><input type="text" name="from" id="from"></input></br>
<label for="to">To: </label><input type="text" name="to" id="to"></input></br>
<label for="subj">Subject: </label><input type="text" name="subj" id="subj"></input></br>
<textarea rows=10 cols=100 name="message"></textarea></br>
<input type="submit" value="Send"/>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我有一个很小的问题,
我想在下拉更改时使用 jQuery 提交我的代码:
$("#mydropDown").change(function(){
$("#myForm").submit();
});
Run Code Online (Sandbox Code Playgroud)
但它没有提交。
我还在 Firebug 控制台中触发了以下代码:
$("#myForm").submit();
Run Code Online (Sandbox Code Playgroud)
它给了我这个输出
[form#myForm]
我不明白有什么问题...:o?
好.我已经看到这个问题已经超过10年未得到答复了..
如何在一键通话中提交和关闭弹出窗口.
建议如此运行.
function saveNClose()
{
document.form.submit();
self.close();
}
this doesn't work because the submit has a redirect, and the self.close is never reached.
Run Code Online (Sandbox Code Playgroud)
function closeLaterNSaveNow();
{
setTimeout("window.close()",5000);
document.form.submit();
}
same problem.. the close is never called because the script for the page is gone.
Run Code Online (Sandbox Code Playgroud)
function closeNowNSubmit()
{
self.close();
document.form.submit();
}
the window closes, but nothing gets saved. server doesn't even get notified of anything..
Run Code Online (Sandbox Code Playgroud)
<input class='btn btn-success' disabled='disabled' id='SubmitFinal' onclick='closeWindow()' type='submit' value='Finish'>
Well then there's no validation of the …Run Code Online (Sandbox Code Playgroud) 我正在为即将到来的拍卖设置一个谷歌表单。当投标人到达拍卖场时,我们会让他们填写一个基本的谷歌表格(即姓名、地址、ID),并且“投标人 ID”是根据响应电子表格中的行号自动生成的。
我希望发生的是一旦提交表单,确认消息就会包含他们的“投标人 ID”。电子表格设置为将投标人 ID 放在 J 列中。这可能吗?如果需要更多信息,请告诉我。
非常感谢。本
我希望仅当我选中“条款和条件”复选框时,才将条纹表格提交到服务器。
我的代码-
<script type="text/javascript">
function isAcceptedTermsAndConditions() {
var isCheckedTermsAndCondition = $('#termsAndCondition').is(":checked");
if (!isCheckedTermsAndCondition) {
$("#termsAndConditionMsg").show();
return false;
} else {
$("#termsAndConditionMsg").hide();
return true;
}
return false;
}
</script>
<div id ="userAgreement">
<div style="margin-left:20px;">
<input type="checkbox" id="termsAndCondition" onclick="isAcceptedTermsAndConditions()"> I have read and agree to the <a style="color: #0000FF" target="_blank" href="#">terms and conditions</a> .
</div>
<span id = "termsAndConditionMsg" class="btn btn-warning" style="margin-left:20px; display:none;padding:10px;margin-top:10px; ">
Please accept the terms and conditions.
</span>
</div>
<form action="/stripe/pay" method="POST" id="payment-form" onsubmit="return isAcceptedTermsAndConditions()">
<label>Card Number</label>
<input type="text" class="form-control" …Run Code Online (Sandbox Code Playgroud) 我有一个带有两个输入字段的登录表单:用户名和密码。
<form method="get" action="../Main/Index">
<p>
<input type="text" name="username" value="" placeholder="username" maxlength="30"></p>
<p>
<input type="password" name="password" value="" placeholder="password" maxlength="25"></p>
<p class="submit">
<input type="submit" name="commit" value="Enter">
</p>
</form>
Run Code Online (Sandbox Code Playgroud)
用户提交表单后,其用户名和密码将显示在浏览器的URL文本框中,如下所示:
http://localhost:53997/Main/Index?username=zm&password=123456789&commit=Enter
我不希望显示他的用户名和密码。
我怎样才能做到这一点?
我有一个父窗口,我在其中使用 window.open() 打开弹出窗口,并且我正在使用 window.opener 方法监视该弹出窗口的返回。我在这里有两个疑问:
代码:
// parent window handling of information returned from the pop-up window
function HandlePopupResult(value) {
alert("The field value is: " + value);
$("input[value='Search']").trigger("click");
}
//pop-up window handling of information to be returned to the parent window on submission
$("#myForm").submit(function() {
window.opener.HandlePopupResult($("#field").val());
window.close();
});
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:如何确保提交已完成,以便我在父窗口中触发搜索点击并关闭此弹出窗口?请让我知道。
我终于能够正确地将信息发送回我的父表单,但我只需要确保我的提交完成。关于确保仅在提交成功后触发我的事件的任何建议?
干杯。
我正在尝试将一个简单的文本输入保存到 WooCommerce 会话中。当用户将东西添加到他们的购物车时创建会话。
我的输入字段存在于自定义页面模板中,该模板将放置在购物车之后但结帐之前的用户流程中:购物车 > 我的模板 > 结帐。
捕获数据的简单表单(自定义模板文件)
<form name="group" method="post" class="checkout woocommerce-checkout" action="http://localhost:/site.dev/my-template">
<div class="group-order">
<p class="form-row form-row woocommerce-validated" id="create_new_group_field">
<label for="create_new_group" class="">Join an existing group</label>
<input type="text" class="input-text " name="create_new_group" id="create_new_group">
</p>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
接收和设置数据(我无法弄清楚何时/如何运行它。在我的自定义页面中)
更新 我已将下面的代码添加到我的页面模板顶部,以便页面处理自身,然后重定向到结帐。
函数 set_and_save_input_to_session() {
if( !is_admin( ) ) {
// User input
if( ! empty( $_POST['create_new_group'] ) ) {
$group_input_value = $_POST['create_new_group'];
// Set session and save data
WC()->session->set( 'group_order_data', $group_input_value );
wp_redirect( 'http://localhost:28/site.dev/checkout' );
exit();
}
} …Run Code Online (Sandbox Code Playgroud) form-submit ×10
javascript ×4
jquery ×4
html ×3
forms ×2
php ×2
asp.net-mvc ×1
google-forms ×1
onblur ×1
popup ×1
post ×1
session ×1
submit ×1
window.open ×1
woocommerce ×1
wordpress ×1