在提交时在控制台中显示表单数据 [英] Show form data in console on submit

查看:264
本文介绍了在提交时在控制台中显示表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提交表单然后将数据也发布到服务器时,是否可以在控制台中显示所有表单数据?

Is it possible to show all the form data in console when the form is submitted and then the data is posted to the server as well?

类似的东西吗?

<form action="http://whatever.com" method="POST" onSubmit="console.log(All Form Data)">

感谢
Ahmar。

Thanks Ahmar.

推荐答案

尝试

$(function() {
  $('form').submit(function() {
    console.log('Input 1: '+$('input[name="input1"]').val() + ' Input 2: '+ $('input[name="input2"]').val()); // etc.
  });
});

或输入Id,然后

<form onSubmit="console.log('Input 1: '+document.getElementById('input1').value + ' Input 2: '+document.getElementById('input2').value)">

这篇关于在提交时在控制台中显示表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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