简体   繁体   English

如何在没有提交按钮的情况下从输入类型文本保存数据

[英]How to Save Data from Input Type Text Without Submit Button

I have a new website. 我有一个新网站。 In this website, the user enters values in the Name & Email in text fields and then the user clicks an anchor to get a unique link. 在此网站中,用户在“名称和电子邮件”的文本字段中输入值,然后单击锚点以获取唯一链接。

Now the thing is, I want to save data from input type text (Name & Email). 现在,我想从输入类型的text (名称和电子邮件)中保存数据。 I know how to do it if there is a submit button, but how can I save data without a submit button? 如果有提交按钮,我知道该怎么做,但是如果没有提交按钮,如何保存数据?

I want to save data in a database via PHP. 我想通过PHP将数据保存在数据库中。

You can use Javascript to submit your form without using a submit button. 您可以使用Javascript提交表单,而无需使用提交按钮。 Use the code written below and modify it accordingly: 使用下面编写的代码并进行相应的修改:

<form name="myform">
     <input type="text" />
     <button class="buttonFinish"></button>
 </form>

 <script type="javascipt">
    $(document).ready(function() {
        $('.buttonFinish').click(function(){
            $('.myform').submit();
        });
    }
  </script>

通过检查if(keycode =='13')在key enter上进行AJAX调用,并通过验证来调用服务器端方法。

暂无
暂无

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

相关问题 如何在html中输入文本作为“提交”按钮? - How to Input type text as submit button in html? 如何在不提交整个表单的情况下单击输入类型“提交”按钮 - How to click on an input type“submit” button without submiting the whole form 如何在不使用提交按钮的情况下从文本框中加载输入? JavaScript的? - How to load input from textbox without using submit button? javascript? 单击表单的“提交”按钮,如何将数据从HTML保存到Excel? - How to save data from HTML to excel, on click on “submit” button of form? 如何最终从输入框类型=数字提交文本字符串? - How to finally submit a text string from an input box type=number? 如何在不单击“提交”按钮的情况下从服务器获取数据? - How to get data from server without clicking on “submit” button? 不使用提交按钮发送输入类型文件 - Send input type file without using submit button Django使用提交按钮而不使用输入标签发布文本 - Django post text using submit button without using input tag jQuery 可以更改输入提交类型的文本但按钮不再可点击 - jQuery can change the text of input submit type but button is no longer clickable 如何从一个javascript变量获取一个值,通过一个按钮用作一个php输入变量,没有或没有提交按钮? - how to take a Value from a javascript variable, to be used as a php input variable via a button, without or not a submit button?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM