[英]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.