Skip to content

Commit 99b1b60

Browse files
committed
[devtools-snippet] add bgrins - Form Control.js
1 parent 9f55af7 commit 99b1b60

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// formcontrols.js
2+
// https://github.com/bgrins/devtools-snippets
3+
// Print out forms and their controls
4+
5+
(function() {
6+
7+
var forms = document.querySelectorAll("form");
8+
9+
for (var i = 0, len = forms.length; i < len; i++) {
10+
var tab = [ ];
11+
12+
console.group("HTMLForm quot;" + forms[i].name + "quot;: " + forms[i].action);
13+
console.log("Element:", forms[i], "\nName: "+forms[i].name+"\nMethod: "+forms[i].method.toUpperCase()+"\nAction: "+forms[i].action || "null");
14+
15+
["input", "textarea", "select"].forEach(function (control) {
16+
[].forEach.call(forms[i].querySelectorAll(control), function (node) {
17+
tab.push({
18+
"Element": node,
19+
"Type": node.type,
20+
"Name": node.name,
21+
"Value": node.value,
22+
"Pretty Value": (isNaN(node.value) || node.value === "" ? node.value : parseFloat(node.value))
23+
});
24+
});
25+
});
26+
27+
console.table(tab);
28+
console.groupEnd();
29+
}
30+
})();

0 commit comments

Comments
 (0)