Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
gather all form elements
<script>
(function() {
var form = document.getElementById('form_837299');
form.addEventListener('submit', function(event) {
// Prevent normal form submit
event.preventDefault();
});
document.getElementById('saveForm').addEventListener('click', function() {
Array.prototype.forEach.call(form.children, function(child) {
var name = child.getAttribute('name');
if ('value' in child && child.type !== 'submit' && name) {
console.log(name, child.value);
// Use jQuery.ajax or a Polymer/core-ajax element to send
// the data to the server
}
});
});
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.