Created
April 25, 2016 10:30
-
-
Save LordJohn42/69e68b4d4db6ce091f482db642320c14 to your computer and use it in GitHub Desktop.
Debug form snipper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[].forEach.call(document.querySelectorAll('form'), function (input) { | |
var table = []; | |
console.group('HTMLForm "' + input.name + '": ' + input.action); | |
console.log('Element: ', input, '\nName: ' + | |
input.name + '\nMethod: ' + input.method.toUpperCase() + | |
'\nAction: ' + input.action || 'null'); | |
['input', 'textarea', 'select'].forEach(function (control) { | |
[].forEach.call(input.querySelectorAll(control), function (node) { | |
table.push({ | |
'Element': node, | |
'Type': node.type, | |
'Name': node.name, | |
'Value': node.value, | |
'Pretty Value': (isNaN(node.value) || node.value === '' ? | |
node.value : parseFloat(node.value)) | |
}); | |
}); | |
}); | |
console.table(table); | |
console.groupEnd(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment