首页 > 其他 > 详细

Add data when form is submitted

时间:2015-05-16 23:18:28      阅读:233      评论:0      收藏:0      [点我收藏+]

Sometimes we want to add extra data to our form and submit them to the server.

We can do this like :

1 var form = document.querySelector(‘form‘);
2     form.onsubmit = function(){
3     var input = document.createElement(‘input‘);
4     input.setAttribute(‘type‘,‘hidden‘);
5         input.setAttribute(‘name‘, elementName);
6         input.setAttribute(‘value‘,elementValue);
7         form.appendChild(input);
8     }

 

Add data when form is submitted

原文:http://www.cnblogs.com/deryck/p/4508818.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!