简体   繁体   English

表单提交到新页面

[英]Form Submit taking to a new page

I have a simple form. 我有一个简单的表格。 On submit (the submit action is a google docs form submission), it takes to a new page with focus on that page. 提交时(提交操作是google docs表单提交),它会转到一个新页面,重点放在该页面上。 I want to keep the focus on the current page. 我想把重点放在当前页面上。

What are my options? 我有什么选择?

This is the code (also present here ) 这是代码(也在此处显示

<html><body>
    <form action="https://docs.google.com/a/rangde.org/spreadsheet/formResponse?formkey=dFlSZkt0TzZTWHJyblBiQlNrcmZvZGc6MQ" method="POST" id="ss-form" target="_blank" onsubmit="submitted=true;">
<br>
<input type="text" name="entry.0.single" value="" class="ss-q-short" id="entry_0" placeholder="Your Name">
<br>
<input type="text" name="entry.1.single" value="" class="ss-q-short" id="entry_1" placeholder="E-mail Address">
<br>
<input type="text" name="entry.2.single" value="" class="ss-q-short" id="entry_2" placeholder="Pledge Amount">
<br>
<input type="submit" name="submit" value="Submit"></form>
    </body>
</html>

Depending on what you're trying to do with the resulting form, (and if you're not comfortable relying js do all the lifting) you could also create a hidden iframe on the page, give it a name, and set the form target to the name of the iframe. 根据您要对结果表单进行的操作(如果您不愿意依靠js来完成所有任务),您还可以在页面上创建一个隐藏的iframe,为其命名,并设置表单目标iframe的名称 This is only if you have no interest in having the user ever see the google page itself. 仅当您对让用户看到Google页面本身不感兴趣时​​。

如果您使用的是jQuery,请尝试http://jquery.malsup.com/form/中的 AjaxForm

A form's action parameter will always take you to that page. 表单的操作参数将始终将您带到该页面。

Here is an example: POST without Form Method (PHP) 这是一个示例: 没有表单方法(PHP)的POST

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM