标签:
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